Skip to content

Commit b674e2f

Browse files
committed
Merge branch 'imba' of https://github.com/allain/js-framework-benchmark into allain-imba
2 parents dd5b6b6 + cd23602 commit b674e2f

File tree

8 files changed

+482
-0
lines changed

8 files changed

+482
-0
lines changed

frameworks/keyed/imba/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Imba</title>
7+
<link href="/css/currentStyle.css" rel="stylesheet" />
8+
</head>
9+
10+
<body>
11+
<div id='main'></div>
12+
<script src='dist/main.js'></script>
13+
</body>
14+
15+
</html>

frameworks/keyed/imba/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "js-framework-benchmark-imba",
3+
"version": "1.0.0",
4+
"description": "Imba demo",
5+
"main": "index.js",
6+
"js-framework-benchmark": {
7+
"frameworkVersionFromPackage": "imba"
8+
},
9+
"scripts": {
10+
"build-dev": "webpack --watch",
11+
"build-prod": "webpack"
12+
},
13+
"keywords": [
14+
"imba",
15+
"webpack"
16+
],
17+
"author": "Allain Lalonde",
18+
"license": "Apache-2.0",
19+
"homepage": "https://github.com/allain/js-framework-benchmark",
20+
"repository": {
21+
"type": "git",
22+
"url": "https://github.com/allain/js-framework-benchmark.git"
23+
},
24+
"devDependencies": {
25+
"terser-webpack-plugin": "1.1.0",
26+
"webpack": "4.22.0",
27+
"webpack-cli": "3.1.2"
28+
},
29+
"dependencies": {
30+
"imba": "^1.4.1"
31+
}
32+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
var A = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"]
2+
var C = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"]
3+
var N = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"]
4+
5+
tag RemoveIcon < span
6+
def build
7+
set('aria-hidden', true)
8+
9+
def render
10+
<self.glyphicon.glyphicon-remove>
11+
12+
tag Row < tr
13+
prop select
14+
prop remove
15+
prop item
16+
prop selected
17+
18+
def onSelect
19+
@select(@item)
20+
21+
def onRemove
22+
@remove(@item)
23+
24+
def render
25+
<self .danger=@selected>
26+
<td.col-md-1> @item:id
27+
<td.col-md-4><a :tap.onSelect> @item:label
28+
<td.col-md-1><a :tap.onRemove><RemoveIcon>
29+
<td.col-md-6>
30+
31+
tag Button
32+
prop id
33+
prop cb
34+
prop title
35+
36+
def render
37+
<self>
38+
<div.col-sm-6.smallpad>
39+
<button.btn.btn-primary.btn-block type='button' id=@id :tap=@cb> @title
40+
41+
var items = []
42+
var selected = 0
43+
var nextId = 1
44+
45+
tag Main
46+
def run
47+
items = buildData(1000)
48+
selected = 0
49+
Imba.commit
50+
51+
def runLots
52+
items = buildData(10000)
53+
selected = 0
54+
55+
def add
56+
items = items.concat(buildData(1000))
57+
58+
def update
59+
var i = 0
60+
while i < items:length
61+
var item = items[i]
62+
items[i] = { id: item:id, label: item:label + ' !!!' }
63+
i = i + 10
64+
Imba.commit()
65+
66+
def select item
67+
selected = item:id
68+
69+
def remove item
70+
items.splice(items.indexOf(item), 1)
71+
Imba.commit()
72+
73+
def clear
74+
items = []
75+
selected = 0
76+
77+
def swapRows
78+
if (items:length > 998)
79+
var temp = items[1]
80+
items[1] = items[998]
81+
items[998] = temp
82+
83+
Imba.commit
84+
85+
86+
def buildData(count)
87+
var newItems = Array.new(count)
88+
var i = 0
89+
while i < count
90+
newItems[i] = {
91+
id: nextId ,
92+
label: "{A[random(A:length)]} {C[random(C:length)]} {N[random(N:length)]}"
93+
}
94+
i = i + 1
95+
nextId = nextId + 1
96+
97+
newItems
98+
99+
def random max
100+
Math.round(Math.random() * 1000) % max
101+
102+
def render
103+
<self>
104+
<div.container>
105+
<div.jumbotron>
106+
<div.row>
107+
<div.col-md-6>
108+
<h1> 'Imba keyed'
109+
<div.col-md-6>
110+
<div.row>
111+
<Button id='run' title='Create 1,000 rows' cb=(do run)>
112+
<Button id="runlots" title="Create 10,000 rows" cb=(do runLots)>
113+
<Button id="add" title="Append 1,000 rows" cb=(do add)>
114+
<Button id="update" title="Update every 10th row" cb=(do update)>
115+
<Button id="clear" title="Clear" cb=(do clear)>
116+
<Button id="swaprows" title="Swap Rows" cb=(do swapRows)>
117+
118+
<table.table.table-hover.table-striped.test-data>
119+
<tbody> for item in items
120+
<Row@{item:id} item=item selected=(selected === item:id) select=(do select(item)) remove=(do remove(item))>
121+
<RemoveIcon.preloadicon>
122+
123+
Imba.mount <Main[{selected: 0, nextId: 0}]>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
const path = require('path')
2+
const webpack = require('webpack')
3+
const TerserPlugin = require('terser-webpack-plugin')
4+
5+
module.exports = {
6+
// mode: 'production',
7+
mode: 'development',
8+
entry: {
9+
main: path.join(__dirname, 'src', 'main.imba')
10+
},
11+
output: {
12+
path: path.join(__dirname, 'dist'),
13+
filename: '[name].js'
14+
},
15+
resolve: {
16+
extensions: ['.imba']
17+
},
18+
module: {
19+
rules: [
20+
{
21+
test: /\.imba$/,
22+
loader: 'imba/loader'
23+
}
24+
]
25+
},
26+
optimization: {
27+
minimizer: [
28+
new TerserPlugin({
29+
terserOptions: {
30+
parse: {
31+
// we want terser to parse ecma 8 code. However, we don't want it
32+
// to apply any minfication steps that turns valid ecma 5 code
33+
// into invalid ecma 5 code. This is why the 'compress' and 'output'
34+
// sections only apply transformations that are ecma 5 safe
35+
// https://github.com/facebook/create-react-app/pull/4234
36+
ecma: 8
37+
},
38+
compress: {
39+
ecma: 5,
40+
warnings: false,
41+
// Disabled because of an issue with Uglify breaking seemingly valid code:
42+
// https://github.com/facebook/create-react-app/issues/2376
43+
// Pending further investigation:
44+
// https://github.com/mishoo/UglifyJS2/issues/2011
45+
comparisons: false
46+
},
47+
mangle: {
48+
safari10: true
49+
},
50+
output: {
51+
ecma: 5,
52+
comments: false,
53+
// Turned on because emoji and regex is not minified properly using default
54+
// https://github.com/facebook/create-react-app/issues/2488
55+
ascii_only: true
56+
}
57+
},
58+
// Use multi-process parallel running to improve the build speed
59+
// Default number of concurrent runs: os.cpus().length - 1
60+
parallel: true,
61+
// Enable file caching
62+
cache: true
63+
})
64+
]
65+
},
66+
plugins: [
67+
new webpack.DefinePlugin({
68+
'process.env': { NODE_ENV: JSON.stringify('production') }
69+
})
70+
]
71+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Imba</title>
7+
<link href="/css/currentStyle.css" rel="stylesheet" />
8+
</head>
9+
10+
<body>
11+
<div id='main'></div>
12+
<script src='dist/main.js'></script>
13+
</body>
14+
15+
</html>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "js-framework-benchmark-imba",
3+
"version": "1.0.0",
4+
"description": "Imba demo",
5+
"main": "index.js",
6+
"js-framework-benchmark": {
7+
"frameworkVersionFromPackage": "imba"
8+
},
9+
"scripts": {
10+
"build-dev": "webpack --watch",
11+
"build-prod": "webpack"
12+
},
13+
"keywords": [
14+
"imba",
15+
"webpack"
16+
],
17+
"author": "Allain Lalonde",
18+
"license": "Apache-2.0",
19+
"homepage": "https://github.com/allain/js-framework-benchmark",
20+
"repository": {
21+
"type": "git",
22+
"url": "https://github.com/allain/js-framework-benchmark.git"
23+
},
24+
"devDependencies": {
25+
"terser-webpack-plugin": "1.1.0",
26+
"webpack": "4.22.0",
27+
"webpack-cli": "3.1.2"
28+
},
29+
"dependencies": {
30+
"imba": "^1.4.1"
31+
}
32+
}

0 commit comments

Comments
 (0)