-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
190 lines (170 loc) · 5.59 KB
/
index.html
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Perspective Benchmark @latest</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
height: 100vh;
background-color: #f0f0f0;
text-align: center;
}
section {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
padding: 20px;
border-radius: 5px;
}
.measurement {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
padding: 20px;
margin: 10px;
width: 300px;
height: 200px;
}
.key {
font-size: 1.5rem;
font-weight: bold;
margin-bottom: 10px;
}
.value {
font-size: 2rem;
font-weight: bold;
color: #007bff;
}
</style>
</head>
<body>
<p id="status">Loading...</p>
<section>
<div class="measurement">
<span class="key">Total</span>
<span id="total-duration" class="value">0</span>
</div>
<div class="measurement">
<span class="key">Worker Create</span>
<span id="worker-create-duration" class="value">0</span>
</div>
<div class="measurement">
<span class="key">Table Create</span>
<span id="table-create-duration" class="value">0</span>
</div>
<div class="measurement">
<span class="key">Table Update</span>
<span id="table-update-duration" class="value">0</span>
</div>
<div class="measurement">
<span class="key">View Create</span>
<span id="view-create-duration" class="value">0</span>
</div>
<div class="measurement">
<span class="key">View ToJson</span>
<span id="view-tojson-duration" class="value">0</span>
</div>
</section>
<section>
<div class="measurement">
<span class="key">jsHeapSizeLimit</span>
<span id="jsHeapSizeLimit" class="value">0</span>
</div>
<div class="measurement">
<span class="key">totalJSHeapSize</span>
<span id="totalJSHeapSize" class="value">0</span>
</div>
<div class="measurement">
<span class="key">usedJSHeapSize</span>
<span id="usedJSHeapSize" class="value">0</span>
</div>
</section>
<script type="module">
import "https://cdn.jsdelivr.net/npm/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"
import perspective from "https://cdn.jsdelivr.net/npm/@finos/perspective/dist/cdn/perspective.js";
const ms = Intl.NumberFormat("en-US", {
style: "unit",
unit: "millisecond",
maximumFractionDigits: 2,
minimumFractionDigits: 2,
});
const mb = Intl.NumberFormat("en-US", {
style: "unit",
unit: "megabyte",
maximumFractionDigits: 2,
minimumFractionDigits: 2,
});
function u(id, value) {
document.getElementById(id).textContent = value;
}
const data = await (await fetch("./data.csv")).text();
const schema = {
key: "string",
string: "string",
float: "float",
integer: "integer",
datetime: "datetime",
boolean: "boolean",
};
const now = performance.now();
let workerCreateDuration = 0;
let tableCreateDuration = 0;
let tableUpdateDuration = 0;
let viewCreateDuration = 0;
let viewToJsonDuration = 0;
const workerCount = 3;
for (let i = 0; i < workerCount; i++) {
const now0 = performance.now();
const worker = await perspective.worker();
workerCreateDuration += performance.now() - now0;
u("worker-create-duration", ms.format(workerCreateDuration));
const tableCount = 100;
for (let j = 0; j < tableCount; j++) {
document.getElementById("status").textContent = `Processing ${
i * tableCount + j + 1
}/${tableCount * workerCount}`;
const now1 = performance.now();
const table = await worker.table(schema);
const now2 = performance.now();
tableCreateDuration += now2 - now1;
await table.update(data);
const now3 = performance.now();
tableUpdateDuration += now3 - now2;
const view = await table.view();
const now4 = performance.now();
viewCreateDuration += now4 - now3;
await view.to_json();
const now5 = performance.now();
viewToJsonDuration += now5 - now4;
const total = Math.round(performance.now() - now);
u("total-duration", ms.format(total));
u("table-create-duration", ms.format(tableCreateDuration));
u("table-update-duration", ms.format(tableUpdateDuration));
u("view-create-duration", ms.format(viewCreateDuration));
u("view-tojson-duration", ms.format(viewToJsonDuration));
u(
"jsHeapSizeLimit",
mb.format(performance.memory.jsHeapSizeLimit / 1024 / 1024)
);
u(
"totalJSHeapSize",
mb.format(performance.memory.totalJSHeapSize / 1024 / 1024)
);
u(
"usedJSHeapSize",
mb.format(performance.memory.usedJSHeapSize / 1024 / 1024)
);
}
}
document.getElementById("status").textContent = `Measured!`;
</script>
</body>
</html>