Skip to content

Commit 4de761b

Browse files
committed
Merge branch 'release/v2.3.0' into master
2 parents 0eec6d6 + eb8e9a5 commit 4de761b

17 files changed

+1777
-2480
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Performance Lab
22

3-
JavaScript performance tests for Handsontable (http://handsontable.github.io/performance-lab/benchmark/)
3+
JavaScript performance tests for Handsontable
44

55
## Install
66

@@ -43,23 +43,23 @@ It serves a page where you can compare your generated results between different
4343

4444
## Usage
4545

46-
##### ```> ./bin/hot-perf run```
46+
##### ```> ./bin/hot-perf run``` (or ```> ./bin/hot-perf r```)
4747

4848
It runs a benchmark by running all spec files defined in the `test/spec` directory. Once completed results are saved to the database.
4949

50-
##### ```> ./bin/hot-perf local-server benchmark-viewer```
50+
##### ```> ./bin/hot-perf local-server benchmark-viewer``` (or ```> ./bin/hot-perf ls bv```)
5151

5252
Runs a local server where you can see the test results.
5353

5454
Arguments:
55-
- ```test-runner``` - It serves a test runner page which is used by protractor to test the Handsontable.
56-
- ```benchmark-viewer``` - It serves a page which is used to view results generated by the `run` command.
55+
- ```test-runner``` (or ```tr```) - It serves a test runner page which is used by protractor to test the Handsontable.
56+
- ```benchmark-viewer``` (or ```bv```) - It serves a page which is used to view results generated by the `run` command.
5757

5858
### Global options:
5959
- ```--hot-version``` - Selects version of the Handsontable to test (it has to be a version which is accessible through [jsdelivr](https://www.jsdelivr.com/)). If not specified the `latest` tag is used. For example `--hot-version=6.2.2`.
6060
- ```--hot-server``` - Selects a server to be used to serve the Handsontable assets. For example `--hot-server=http://localhost:8082`. If
6161
used the assets are loaded from `dist` directory, such as `http://localhost:8082/dist/handsontable.full.css`.
62-
- ```--test-name``` - The name under which the test will be saved. For example `--test-name=my-feature`.
62+
- ```--test-name``` - The name under which the test will be saved. For example `--test-name=my-feature`. If a test by that name is already stored, it will be replaced with the new test results.
6363

6464
## License
6565

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ services:
66
mongo:
77
container_name: performance-lab-mongodb
88
image: mongo:4
9-
command: --smallfiles
109
ports:
1110
- 27017:27017
1211
environment:
@@ -21,6 +20,7 @@ services:
2120
ports:
2221
- 8081:8081
2322
environment:
23+
ME_CONFIG_MONGODB_SERVER: mongo
2424
ME_CONFIG_MONGODB_ADMINUSERNAME: root
2525
ME_CONFIG_MONGODB_ADMINPASSWORD: root
2626
depends_on:

lib/cli.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@ const semver = require('semver');
33
const config = require('./config');
44
const { version: packageVersion, engines } = require('./../package');
55

6-
const hotVersionRegExp = /^\d{1,3}\.\d{1,3}\.\d{1,3}$/;
6+
const appToServeMap = new Map([
7+
['tr', 'test-runner'],
8+
['bv', 'benchmark-viewer'],
9+
]);
10+
const hotVersionRegExp = /^(\d{1,3}\.\d{1,3}\.\d{1,3}|latest)$/;
711

812
function parseArgs() {
913
program
1014
.version(packageVersion)
1115
.description('JavaScript performance tests for Handsontable')
12-
.command('local-server', 'Run a local server ("test-runner" or "benchmark-viewer").')
13-
.argument('<app_to_serve>', 'Type of the application to serve ("test-runner" or "benchmark-viewer")', /^(test\-runner|benchmark\-viewer)$/, 'test-runner')
16+
.command('local-server', 'Run a local server ("test-runner", "tr" or "benchmark-viewer", "bv").')
17+
.alias('ls')
18+
.argument('<app_to_serve>', 'Type of the application to serve ("test-runner" or "benchmark-viewer")', /^(test\-runner|tr|benchmark\-viewer|bv)$/, 'test-runner')
1419
.option('--hot-version <version>', 'The Handsontable <version> which will be used for running a benchmark.', hotVersionRegExp)
1520
.option('--hot-server <url>', 'The server <url> which will be used to serve Handsontable assets from.')
1621
.action((args, options) => {
17-
require('./commands/local-server')(args.appToServe, parseInt(config.SERVER_PORT, 10) + 1, options);
22+
require('./commands/local-server')(
23+
appToServeMap.get(args.appToServe) ?? args.appToServe,
24+
parseInt(config.SERVER_PORT, 10) + 1,
25+
options
26+
);
1827
})
1928
.command('run', 'Run a benchmark.')
29+
.alias('r')
2030
.option('--hot-version <version>', 'The Handsontable <version> which will be used for running a benchmark.', hotVersionRegExp)
2131
.option('--hot-server <url>', 'The server <url> which will be used to serve Handsontable assets from.')
2232
.option('--test-name <name>', 'The <name> name under which the test will be saved.')
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<!doctype html>
2+
<head>
3+
<title></title>
4+
<link rel="stylesheet" href="{{ urls.style }}">
5+
<script src="{{ urls.script }}"></script>
6+
<script src="/js/test-runner.js"></script>
7+
<style>
8+
#example {
9+
width: 1250px;
10+
height: 800px;
11+
overflow: hidden;
12+
}
13+
.currentRow, .currentCol {
14+
background-color: #ccc !important;
15+
}
16+
</style>
17+
</head>
18+
<html>
19+
<body>
20+
21+
<div id="example"></div>
22+
<script>
23+
Handsontable.renderers.registerRenderer('flagRenderer', function (instance, td, row, col, prop, value, cellProperties) {
24+
var currencyCode = value;
25+
26+
while (td.firstChild) {
27+
td.removeChild(td.firstChild);
28+
}
29+
var flagElement = document.createElement('DIV');
30+
31+
flagElement.className = 'flag ' + currencyCode;
32+
flagElement.textContent = '[flag]-' + value;
33+
td.appendChild(flagElement);
34+
});
35+
Handsontable.renderers.registerRenderer('firstRowRenderer', function (instance, td, row, col, prop, value, cellProperties) {
36+
Handsontable.renderers.TextRenderer.apply(this, arguments);
37+
td.style.fontWeight = 'bold';
38+
td.style.color = 'green';
39+
td.style.background = '#CEC';
40+
});
41+
Handsontable.renderers.registerRenderer('firstColRenderer', function (instance, td, row, col, prop, value, cellProperties) {
42+
Handsontable.renderers.TextRenderer.apply(this, arguments);
43+
td.style.fontWeight = 'bold';
44+
td.style.color = 'red';
45+
td.style.background = '#eecccc';
46+
});
47+
var columns = [];
48+
var baseColumns = [
49+
{
50+
type: 'numeric',
51+
width: 40,
52+
},
53+
{
54+
renderer: 'flagRenderer'
55+
},
56+
{ type: 'text' },
57+
{ type: 'text' },
58+
{ type: 'text' },
59+
{ type: 'text', width: 100, },
60+
{ type: 'text' },
61+
{ type: 'text' },
62+
{ type: 'text' },
63+
{ type: 'text' },
64+
{ type: 'text', width: 150, },
65+
{
66+
type: 'numeric',
67+
numericFormat: {
68+
pattern: '0.0000'
69+
}
70+
},
71+
{
72+
type: 'date',
73+
dateFormat: 'MM/DD/YYYY'
74+
},
75+
{
76+
type: 'numeric',
77+
numericFormat: {
78+
pattern: '0.00%'
79+
},
80+
width: 90,
81+
},
82+
{
83+
type: 'autocomplete',
84+
},
85+
{
86+
type: 'dropdown',
87+
},
88+
];
89+
90+
for (var i = 0; i < 1000; i++) {
91+
columns.push(JSON.parse(JSON.stringify(baseColumns[i % (baseColumns.length)])));
92+
}
93+
94+
var hot = new Handsontable(example, {
95+
licenseKey: 'non-commercial-and-evaluation',
96+
// data: Handsontable.helper.createSpreadsheetData(10000, 100),
97+
data: Handsontable.helper.createSpreadsheetData(1000, 100),
98+
// columns: columns,
99+
rowHeaders: true,
100+
colHeaders: true,
101+
currentRowClassName: 'currentRow',
102+
currentColClassName: 'currentCol',
103+
// colWidths: 30,
104+
viewportRowRenderingOffset: 0,
105+
viewportColumnRenderingOffset: 0,
106+
afterModifyTransformStart: function(coords, rowTransformDir, colTransformDir) {
107+
if (rowTransformDir === -1) {
108+
coords.col = coords.col + 20;
109+
}
110+
if (rowTransformDir === 1) {
111+
coords.col = coords.col - 20;
112+
}
113+
},
114+
fixedColumnsLeft: 2,
115+
fixedRowsTop: 2,
116+
cells: function(row, col) {
117+
var cellProperties = {};
118+
var data = this.instance.getDataAtCell(row, col);
119+
120+
if (row === 0 || data === 'readOnly') {
121+
cellProperties.readOnly = true;
122+
}
123+
if (row === 0 || row === 1) {
124+
cellProperties.renderer = 'firstRowRenderer';
125+
}
126+
if (col === 0 || col === 1) {
127+
cellProperties.renderer = 'firstColRenderer';
128+
}
129+
130+
if (row === 0 && col === 0) {
131+
cellProperties.className = 'htRight';
132+
}
133+
if (row === 1 && col === 1) {
134+
cellProperties.className = 'htRight';
135+
}
136+
if (row === 3 && col === 4) {
137+
cellProperties.className = 'htRight';
138+
}
139+
140+
return cellProperties;
141+
},
142+
renderer: function(instance, TD, row, col, prop, value, cellProperties) {
143+
Handsontable.renderers.BaseRenderer.call(this, instance, TD, row, col, prop, value, cellProperties);
144+
145+
value = row % 2 ? value : (value + '<b>' + value.substr(0, 2) + '</b>');
146+
147+
TD.innerHTML = value;
148+
TD.setAttribute('id-row', row);
149+
TD.setAttribute('id-col', col);
150+
TD.setAttribute('id-prop', prop);
151+
TD.classList.add('class-' + row);
152+
TD.style.color = '#999';
153+
},
154+
// renderer: function(instance, TD, row, col, prop, value, cellProperties) {
155+
// TD.classList.add('test-class');
156+
// TD.innerHTML = '.<b>' + value + '</b>';
157+
// },
158+
// autoColumnSize: true, // AutoColumnSize is asynchronous so it has to be disabled to not inferred stat results
159+
});
160+
</script>
161+
<script>document.writeln('Build date: ' + Handsontable.buildDate + ', version: ' + Handsontable.version)</script>
162+
<script>
163+
setTimeout(function() {
164+
document.title = 'ready'; // Mark that the runner page is ready to tests
165+
}, 2000);
166+
</script>
167+
</body>
168+
</html>

0 commit comments

Comments
 (0)