TechEmpower/FrameworkBenchmarks — pull request #235 by knappador (2013-05-02 23:15:20+00:00)
Title: Improvements for the multi-query tests.

These changes will work for both django and django_stripped

I've explained the changes line by line so that anyone can run them many ways. I tested out certain portions (like declaring dictionaries on the fly with string literals instead of identifiers pointing to the literals) to make sure this is somewhat nice. Using partials and eliminating de-references (dot-notation) removes a lot of call-stack overhead, not to mention making downstream code really succinct for what it's doing. If you don't believe me, too bad; here's proof:
# with random partial
In [19]: %timeit [rp() for x in xrange(1000)]
10000 loops, best of 3: 97.2 us per loop

# with unnecessary dereference
In [20]: %timeit [random.randint(1000) for x in xrange(1000)]
10000 loops, best of 3: 146 us per loop

In [21]: ri = random.randint

# without frivolous dereference
In [22]: %timeit [ri(1000) for x in xrange(1000)]
10000 loops, best of 3: 108 us per lo