![]() HttpRouter was the first router (I know of) that managed to serve all the static URLs without a single heap allocation. The fastest router only needs 1.8% of the time http.ServeMux needs. The logs below show, that http.ServeMux has only medium performance, compared to more feature-rich routers. The third number is the amount of heap memory allocated in bytes, the last one the average number of allocations made per repetition. The second column shows the time in nanoseconds that a single repetition takes. If you are unfamiliar with the go test -bench tool, the first number is the number of repetitions the go test tool made, to get a test running long enough for measurements. In the StaticAll benchmark each of 157 URLs is called once per repetition (op, operation). The only intention of this benchmark is to allow a comparison with the default router of Go's net/http package, http.ServeMux, which is limited to static routes and does not support parameters in the route pattern. It might not be a realistic URL-structure. It is just a collection of random static paths inspired by the structure of the Go directory. The Static benchmark is not really a clone of a real-world API. But it gives us a first hint how efficient or wasteful a router works. As long as the router doesn't require Megabytes of memory, it should be no deal breaker. Moreover main memory is cheap and usually not a scarce resource. The routing structure of Pat is simple - probably too simple. ![]() Now, before everyone starts reading the documentation of Pat, this low memory consumption comes at the price of relatively bad routing performance. The first place goes to Pat, followed by HttpRouter and Goji. I'm pretty sure you can detect a pattern □ Router The best 3 values for each test are bold. The following table shows the memory required only for loading the routing structure for the respective API.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |