Monday, August 26, 2013

Json makes tuples to list

While working on json format, came across something interesting.

sample_list  = [(1,2),(3,4)]
print json.dumps(sample_list)  # [[1,2],[3,4]]

As we can see here, json isnt preserving tuples. On searching, I got to know, JSON doesnt understand tuples. These are the basic data types for json(from Wikipedia )

JSON's basic types are:
  • Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type)
  • Object (an unordered collection of key:value pairs with the ':' character separating the key and the value, comma-separated and enclosed in curly braces; the keys must be strings and should be distinct from each other)
Here are some solutions for the same on stackoverflow.

Cheers..!!

Thursday, August 22, 2013

Lesser known Stress testing Utility - Siege

Siege is a HTTP/HTTPS Stress testing tool.

Here is the man page for it.

Here is short intro from the man page -

Siege is a multi-threaded http load testing and benchmarking utility. It was designed to let web developers measure the performance of their code under duress. It allows one to hit a web server with a configurable number of concurrent simulated users.


A basic command for testing a web app locally is
siege http://localhost:8000/?q=pants -c10 -t10s
c -> number of concurrent users
t -> time for running tests for.


Hope it was useful.