Mongrel2 Profiler Filter: Take 2
I wrote about creating the profiler filter for Mongrel2 web/application server before. The filter was dead simple and measured the time it took to serve a simple request. This profiler did not include the per-connection request profiling since it saved the data into global ProfilerSession struct which recorded times of receiving the request and sending the response. Since this was just a proof-of-concept thing to get to know how one can write a filter for Mongrel2 - it didn’t have a good architecture to begin with.
Wanting to improve it I wrote to Mongrel2 librelist seeking advice. I’m not a good C programmer, so Tordek helped me a lot by virtually rewriting the whole filter to handle per-connection profiling of different requests as well cleaning up the code and making it shorter.
Here’s the code in whole 76 lines of its glory:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
Same setup instructions apply. You can find them in previous post.