Under OS X you have access to the FreeBSD traffic shaping util ipfw. First of all you need to define some rule which will work on local interactions.
sudo ipfw add 1 pipe 1 src-ip 127.0.0.1
sudo ipfw add 1 pipe 2 dst-ip 127.0.0.1
After that we can set up the connection speed, and also I like to add some delay to emulate a request to a remote server
sudo ipfw pipe 1 config bw 40Byte/s delay 100ms
After that all your local requests will slow down to 40Byte/s speed with a realistic 100ms response delay.
When you have done with your tests, you can remove the rule with the following command.
sudo ipfw delete 1
Now it is all interesting but lets wrap it up in a simple shell script so we didn't need to memorize all the fancy calls.
sudo touch /usr/bin/slowdown
sudo chmod +x /usr/bin/slowdown
After that open the file with your favorite editor and write the following little script
if [ $1 = "clear" ] ; then
ipfw delete 1
ipfw add 1 pipe 1 src-ip 127.0.0.1
ipfw add 1 pipe 2 dst-ip 127.0.0.1
ipfw pipe 1 config bw $1KByte/s delay 100ms
Now you can create and remove pipes just like that
sudo slowdown 40
And to remove the rule call it like that
sudo slowdown clear
That's all about it. Happy testing!