public
Description: Lua binding to the discount C implementation of the Markdown text-to-html markup system
Homepage: http://asbradbury.org/projects/lua-discount/
Clone URL: git://github.com/asb/lua-discount.git
lua-discount / bench.lua
100644 33 lines (24 sloc) 0.582 kb
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
require("Benchmark")
 
require('markdown')
discount = require('discount')
 
 
local function read_file(fn)
  local file = assert(io.open(fn))
  local contents = assert(file:read('*a'))
  file:close()
  return contents
end
 
local bench = Benchmark:new()
 
local REPS = 100
local input = read_file("syntax.text")
print("Benchmarking using http://daringfireball.net/projects/markdown/syntax.text\n")
 
bench:add("lua-discount", function()
  for i=1, REPS do
    discount(input)
  end
end)
 
bench:add("markdown.lua", function()
  for i=1, REPS do
    markdown(input)
  end
end)
 
bench:run()