Code Tidbits

Code Tidbits: wrk pt.1

I have this plan to do some write up series related to programming and such, mostly as another form of practicing C systems programming. Just when I wondered about what topic I should write, I found this gem written by Will Glozer. So I think I can study the source code and write some little explanation here and there about the code, hence the tidbits. Feel free to critic and correct things if you find mistakes on this. It would be my honour.

How things work from here

I’ll make the writings into several parts, each explaining a module or two around the project. I will start from the nuts and bolts first, going to the main program/module at the last part.

Intro to wrk

wrk, as described by its author, is a modern http benchmarking tool. It’s written in C, event-based, and some part of it is actually stolen from redis sorce base. It’s fairly easy to use, and the stats is comprehensive, you can grab the source from here. Just type make to compile, and you’ll be ready to benchmark your website.

I kinda like the source code for its simplicity and learn a lot from them. The library used from redis including zmalloc and ae. I will going into zmalloc, before that, lets see this aprintf first.

Read more