-
Notifications
You must be signed in to change notification settings - Fork 3
/
profile.coffee
99 lines (90 loc) · 2.45 KB
/
profile.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
coffeemugg = require './src/coffeemugg'
profiler = require 'profiler'
log = console.log
data =
title: 'test'
inspired: no
users: [
{email: 'house@gmail.com', name: 'house'}
{email: 'cuddy@gmail.com', name: 'cuddy'}
{email: 'wilson@gmail.com', name: 'wilson'}
]
coffeemugg_template = ->
@doctype 5
@html lang: 'en', ->
@head ->
@meta charset: 'utf-8'
@title data.title
@style '''
body {font-family: "sans-serif"}
section, header {display: block}
'''
@body ->
@section ->
@header ->
@h1 data.title
if data.inspired
@p 'Create a witty example'
else
@p 'Go meta'
@ul ->
for user in data.users
@li user.name
@li -> @a href: "mailto:#{user.email}", -> user.email
coffeemugg_template_args = (data) ->
@doctype 5
@html lang: 'en', ->
@head ->
@meta charset: 'utf-8'
@title data.title
@style '''
body {font-family: "sans-serif"}
section, header {display: block}
'''
@body ->
@section ->
@header ->
@h1 data.title
if data.inspired
@p 'Create a witty example'
else
@p 'Go meta'
@ul ->
for user in data.users
@li user.name
@li -> @a href: "mailto:#{user.email}", -> user.email
coffeemugg_template_context = ->
@doctype 5
@html lang: 'en', ->
@head ->
@meta charset: 'utf-8'
@title @data.title
@style '''
body {font-family: "sans-serif"}
section, header {display: block}
'''
@body ->
@section ->
@header ->
@h1 @data.title
if @data.inspired
@p 'Create a witty example'
else
@p 'Go meta'
@ul ->
for user in @data.users
@li user.name
@li -> @a href: "mailto:#{user.email}", -> user.email
benchmark = (title, code) ->
start = new Date
profiler.resume()
for i in [1..15000]
code()
profiler.pause()
log "#{title}: #{new Date - start} ms"
@run = ->
benchmark 'CoffeeMugg (none)', -> coffeemugg.render coffeemugg_template
#benchmark 'CoffeeMugg (args)', -> coffeemugg.render coffeemugg_template_args, null, data
#benchmark 'CoffeeMugg (context)', -> coffeemugg.render coffeemugg_template_context, context: {data: data}
#benchmark 'CoffeeMugg (format) (none)', -> coffeemugg.render coffeemugg_template, format: on
@run()