cassowary.js
cassowary.js copied to clipboard
Performance Benchmarks
I noticed your comment on Greg Badro's blog stating you saw a 2x speed boost from the original js port. Awesome! Do you have any tests that demonstrate this, jsperf or whatever? Did you see a general speed boost or for particular cases? Is the performance boost to just from removing external libraries?
Heya:
I'm still pretty early in the profiling. I've been mostly working to get rid of external dependencies 'till now, but it is getting somewhat faster as I find and kill dumb code that's probably the result of the transliteration (not stupid assumptions in the original...language impedance mismatches do that to you EVERY TIME).
Something like JSPerf is a much better idea than what I've been doing. I'll add it to my TODO list.
The most recent code is ~5-6x faster than the original on the unit tests. Here's some truncated before/after. The headline numbers are 1.78s for the original vs. 0.325 for the refactored code. More to do, though:
obelisk:js slightlyoff$ /projects/v8_edge/d8 --harmony CL-loads.js
...
addDel:
starting timing test. nCns = 100, nSolvers = 10, nResolves = 50
done building data structures
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.014
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.027
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.052
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.067
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.082
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.097
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.111
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.124
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.138
done adding 61 constraints [500 attempted, 0 exceptions]
time = 0.155
Editing vars with indices 74, 54
about to start resolves
done resolves -- now ending edits
total time = 1.782
number of constraints: 100
number of solvers: 10
numbers of resolves: 50
tests: 1
time to add (ms): 155
time to edit (ms): 23
time to resolve (ms): 641
time to edit (ms): 13
add time per solver (ms): 0.155
edit time per solver (ms): 1.15
resolve time per resolve (ms): 1.282
time to end edits per solver (ms): 0.65
obelisk:cassowary-js-refactor slightlyoff$ /projects/v8_edge/d8 --harmony run-cl-tests.js
...
addDel:
starting timing test. nCns = 100, nSolvers = 10, nResolves = 50
done building data structures
time = 0.175
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.003
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.005
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.008
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.01
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.012
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.014
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.016
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.019
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.021
done adding 63 constraints [500 attempted, 0 exceptions]
time = 0.023
Editing vars with indices 70, 56
about to start resolves
done resolves -- now ending edits
total time = 0.325
number of constraints: 100
number of solvers: 10
numbers of resolves: 50
tests: 1
time to add (ms): 23
time to edit (ms): 5
time to resolve (ms): 62
time to edit (ms): 2
add time per solver (ms): 0.023
edit time per solver (ms): 0.25
resolve time per resolve (ms): 0.124
time to end edits per solver (ms): 0.1
I found some more useless allocations/iteration. It's 8x faster now.
that's significant!