为什么Go的Martini的性能不如Play Framework 2.2.x

I wrote two equal projects in Golang+Martini and Play Framework 2.2.x to compare it's performance. Both have 1 action that render 10K HTML View. Tested it with ab -n 10000 -c 1000 and monitored results via ab output and htop. Both uses production confs and compiled views. I wonder about results:

Play: ~17000 req/sec + constant 100% usage of all cores of my i7 = ~0.059 msec/req
Martini: ~4000 req/sec + constant 70% usage of all cores of my i7 = ~0.25 msec/req

...as I understand martini is not bloated, so why it 4.5 times slower? Any way to speedup?

Update: Added benchmark results

Golang + Martini:

./wrk -c1000 -t10 -d10 http://localhost:9875/
Running 10s test @ http://localhost:9875/
  10 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   241.70ms  164.61ms   1.16s    71.06%
    Req/Sec   393.42     75.79   716.00     83.26%
  38554 requests in 10.00s, 91.33MB read
  Socket errors: connect 0, read 0, write 0, timeout 108
Requests/sec:   3854.79
Transfer/sec:      9.13MB

Play!Framework 2:

./wrk -c1000 -t10 -d10 http://localhost:9000/
Running 10s test @ http://localhost:9000/
  10 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    32.99ms   37.75ms 965.76ms   85.95%
    Req/Sec     2.91k   657.65     7.61k    76.64%
  276501 requests in 10.00s, 1.39GB read
  Socket errors: connect 0, read 0, write 0, timeout 230
Requests/sec:  27645.91
Transfer/sec:    142.14MB

Martini running with runtime.GOMAXPROCS(runtime.NumCPU())

I want to use golang in production, but after this benchmark I don't know how can I make such decision...

Any way to speedup?

@Kr0e, right! I figured out that heavy use of reflection in DI of martini makes it perform slowly. I moved to gorilla mux and wrote some martini-style helpers and got a wanted performance.

@Cory LaNou: I can't accept yours comment) Now I agree with you, no framework in prod is good idea. Thanks

@user3353963: See my question: Both uses production confs and compiled views

I made a simple martini app with rendering 1 html file and it's quite fast:

  ✗ wrk -t10 -c1000 -d10s  http://localhost:3000/
  Running 10s test @ http://localhost:3000/
    10 threads and 1000 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency    31.94ms   38.80ms 109.56ms   83.25%
      Req/Sec     3.97k     3.63k   11.03k    49.28%
    235155 requests in 10.01s, 31.17MB read
    Socket errors: connect 774, read 0, write 0, timeout 3496
  Requests/sec:  23497.82
  Transfer/sec:      3.11MB

Macbook pro i7. This is app https://gist.github.com/zishe/9947025 It helps if you show your code, perhaps you didn't disable logs or missed something.

But timeout 3496 seems bad.

add this code:

func init(){
  martini.Env = martini.Prod
}

sorry, your code have done.