jaekwon/CoffeeMugg — pull request #4 by wmertens (2012-08-17 12:38:35+00:00)
Title: Optimization

I switched to a flat string generation model, how do you like it?

I had to remove the debug string because it no longer made sense.

I also changed the repeat times of the benchmarking so the numbers fluctuate less and I switched to benchmarking coffeecup instead of coffeekup (which is no longer maintained).

Benchmark shows a 10-15% speedup for normal and 50% for formatted:

Before (15000 runs):
```
CoffeeMugg (none): 2675 ms
CoffeeMugg (args): 2745 ms
CoffeeMugg (context): 2660 ms
CoffeeMugg (format) (none): 3796 ms
```
After:
```
CoffeeMugg (none): 2316 ms
CoffeeMugg (args): 2423 ms
CoffeeMugg (context): 2389 ms
CoffeeMugg (format) (none): 2414 ms
```

There is still a ways to go vs CoffeeCup (`CoffeeKup (function, cache on): 1250 ms`), I suppose the frequent lookups on `this` make the mugg approach slower, but I much prefer the flexibility and non-magicness.

All in all it's still fast enough for production use and maybe there could be some caching done on repeated renderings of the same template with different data.