4 ms·
parsed = http_parser_execute(parser, &settings_null, buf, strlen(buf)); assert(parsed == strlen(buf)); He's calling strlen(buf) twice here. There's no guarant
by halayli 12y ago
parsed = http_parser_execute(parser, &settings_null, buf, strlen(buf));
assert(parsed == strlen(buf));
He's calling strlen(buf) twice here. There's no guarantee that this is optimized at compile time. Usually len of buf is determined from read/recv system calls and for a fair comparison strlen should be removed here.
- Ono-Sendai 12y agoassert only runs in debug mode anyway.
- haberman 12y agoIt runs unless NDEBUG is defined, which the author did not do according to his methodology. Anyway I looked at the assembly output and strlen() is optimized away.
- webreac 12y agoI really do not like when bad habits are encouraged by the optimizer.
- halayli 12y agono, that's not correct. http://pubs.opengroup.org/onlinepubs/009695399/functions/assert.html http://pubs.opengroup.org/onlinepubs/009695399/functions/ass...
- aidenn0 12y ago"Forcing a definition of the name NDEBUG, either from the compiler command line or with the preprocessor control statement #define NDEBUG ahead of the #include <assert.h> statement, shall stop assertions from being compiled into the program"
- fukamachi 12y agoNo difference even though I ran the benchmark again after removing the line.
- jeffreyrogers 12y agoAny good compiler will optimize that out. (Actually, even a bad compiler will optimize that out... it's a really easy optimization).