Skip to content

Commit

Permalink
Cakefile, benchmark.coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
aeosynth committed Feb 10, 2011
1 parent 499da16 commit 04188ed
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 36 deletions.
1 change: 1 addition & 0 deletions Cakefile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
task 'bench', 'benchmark ck with coffeekup', -> require './benchmark'
37 changes: 37 additions & 0 deletions benchmark.coffee
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,37 @@
ck = require '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.render ck_template, { context }
benchmark 'coffeekup', -> coffeekup_template { context }
39 changes: 3 additions & 36 deletions readme.md
Original file line number Original file line Diff line number Diff line change
@@ -1,41 +1,8 @@
a smaller, faster [coffeekup](https://github.com/mauricemach/coffeekup) a smaller, faster [coffeekup](https://github.com/mauricemach/coffeekup)


ck = require 'ck' $ cake bench
coffeekup = require 'coffeekup' ck: 251ms

coffeekup: 287ms
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"

benchmark 'ck', -> ck.render ck_template, { context }
benchmark 'coffeekup', -> coffeekup_template { context }


#subtractions #subtractions


Expand Down

0 comments on commit 04188ed

Please sign in to comment.