vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

Inline bufputc() and bufgrow() #7

Closed bnoordhuis closed 13 years ago

bnoordhuis commented 13 years ago

A disproportionate amount of time is spent in bufputc() and bufgrow(). The pull request inlines them for a pretty big jump in performance. Check it out:

 56.64     12.30    12.30 13738889     0.00     0.00  rndr_smartypants
 14.57     15.47     3.17 197493610     0.00     0.00  bufputc
  9.26     17.48     2.01    10969     0.18     1.85  parse_block
  8.75     19.38     1.90 190226522     0.00     0.00  bufgrow
  4.19     20.29     0.91    12384     0.07     1.71  ups_markdown
  1.84     20.69     0.40 13726503     0.00     0.00  char_autolink
  1.52     21.02     0.33    11365     0.03     0.03  rndr_paragraph

Before (median of three):

$ time ./benchmark
real    0m40.680s
user    1m15.200s
sys     0m0.310s

After (idem):

$ time ./benchmark
real    0m10.395s
user    0m20.260s
sys     0m0.140s

If that isn't low hanging fruit, I don't know what is. :-)

vmg commented 13 years ago

Hey, thanks for the performance boost. I hadn't even profiled the library yet, been too busy implementing the thousand features that the original was lacking. ;d