Siege, custom variables and SED

  • Sumo

Siege, custom variables and SED

You know I love Linux, bash and well I try to be in the command line as much as possible. You may consider it archaic and intuitive but it is all about perception.

It is my comfort zone a place where we live by the boolean law: It works and it doesn’t.

So today I had to format a list of 1500 URLs I got from GA, something like this:

/clothing/women.html
/clothing/kids.html
/clothing/men.html
/shirts.html

But I needed them like this:

http://www.example.com/clothing/women.html
http://www.example.com/clothing/kids.html
http://www.example.com/clothing/men.html
http://www.example.com/shirts.html

In this example a simple find and replace is enough but with 1500 you can’t simply think that find and replace will do the work. Well it would but as I get bored really fast, it is better to automate.

Siege custom variables

SIEGE supports custom variables like bash… madness.

So I can rewrite the file above like this:

URL=http://www.example.com/
$(URL)clothing/women.html
$(URL)clothing/kids.html
$(URL)clothing/men.html
$(URL)shirts.html

WOW… Now it becomes really simple to do multi store testing in Magento or simply try different protocols, did I hear test https pages?

But we still have a problem, how are we going to do fix the URLS?

SED to the rescue

SED and AWK made it to my magento toolbox so it stands to reason to believe that I used them consistently.

With SED I can could do something like this:

sed -i "s/^\//\$\(URL\)/g" siege.file.urls

Your guess is as good as mind, magically SED finds any line in the file that starts(^) with a trailing slash(/) and replaces it them with $(URL)

So this:

/clothing/women.html
/clothing/kids.html
/clothing/men.html
/shirts.html

Now becomes this:

$(URL)clothing/women.html
$(URL)clothing/kids.html
$(URL)clothing/men.html
$(URL)shirts.html

Automatically… and all we need to do is add: URL=http://www.example.com/ at the beginning of the file

Let the siege begins…

siege -f siege.file.urls

Transactions:		           4 hits
Availability:		      100.00 %
Elapsed time:		       18.91 secs
Data transferred:	        0.09 MB
Response time:		        8.86 secs
Transaction rate:	        0.21 trans/sec
Throughput:		        0.00 MB/sec
Concurrency:		        1.87
Successful transactions:           4
Failed transactions:	           0
Longest transaction:	       15.70
Shortest transaction:	        0.43

So there you have it – why I live in the command line because it is pure automation, a good source of sorcery and arts (PS I just recently found out Kate Editor allows to do sed like replacements and of course you can do all this with VIM out of the box)

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Author: Luis Tineo

Husband, Father, performance improvement junkie, biker and video gamer, Linux user and in my day job I'm a Software Engineer at BuyerQuest.

Share This Post On