Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cakefile, benchmark.coffee

  • Loading branch information...
commit 04188ed9e8875cce6423754be6b8983ed432380c 1 parent 499da16
@aeosynth authored
Showing with 41 additions and 36 deletions.
  1. +1 −0  Cakefile
  2. +37 −0 benchmark.coffee
  3. +3 −36 readme.md
View
1  Cakefile
@@ -0,0 +1 @@
+task 'bench', 'benchmark ck with coffeekup', -> require './benchmark'
View
37 benchmark.coffee
@@ -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 }
View
39 readme.md
@@ -1,41 +1,8 @@
a smaller, faster [coffeekup](https://github.com/mauricemach/coffeekup)
- 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"
-
- benchmark 'ck', -> ck.render ck_template, { context }
- benchmark 'coffeekup', -> coffeekup_template { context }
+ $ cake bench
+ ck: 251ms
+ coffeekup: 287ms
#subtractions
Please sign in to comment.
Something went wrong with that request. Please try again.