-
Notifications
You must be signed in to change notification settings - Fork 10
/
benchmark.coffee
39 lines (34 loc) · 989 Bytes
/
benchmark.coffee
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
34
35
36
37
38
39
ck = require './lib/ck'
coffeekup = require 'coffeekup'
template = ->
doctype 5
html ->
head ->
title @title
body ->
div id: 'content', ->
for post in @posts
div class: 'post', ->
p post.name
div post.comment
form method: 'post', ->
ul ->
li -> input name: 'name'
li -> textarea name: 'comment'
li -> input type: 'submit'
context =
title: 'my first website!'
posts: []
ck_template = ck.compile template
coffeekup_template = coffeekup.compile template
benchmark = (name, fn) ->
start = new Date
for i in [0..10000]
fn()
end = new Date
console.log "#{name}: #{end - start}ms"
exports =
benchmark 'ck', -> ck_template context: context
benchmark 'ck (format)', -> ck_template context: context, format: true
benchmark 'coffeekup', -> coffeekup_template context: context
benchmark 'coffeekup (format)', -> coffeekup_template context: context, format: true