-
Notifications
You must be signed in to change notification settings - Fork 29
/
hidden_class.js
52 lines (45 loc) · 1.09 KB
/
hidden_class.js
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
// perhaps microbenchmarking here make no sense
// can anyone provide a more meaningful cases?
// about hidden class: https://developers.google.com/v8/design#prop_access
function withoutHiddenClass() {}
withoutHiddenClass.prototype.timeout = timeout;
withoutHiddenClass.prototype.url = url;
withoutHiddenClass.prototype.type = type;
function withHiddenClass() {
this._timeout = 0;
this._url = "";
this._type = "";
}
withHiddenClass.prototype.timeout = timeout;
withHiddenClass.prototype.url = url;
withHiddenClass.prototype.type = type;
function timeout(timeout) {
this._timeout = timeout;
}
function url(url) {
this._url = url;
}
function type(type) {
this._type = type;
}
const cases = [
{
name: "withoutHiddenClass",
fn: function () {
var obj = new withoutHiddenClass();
obj.timeout(1);
obj.url("google.com");
obj.type("get");
},
},
{
name: "withHiddenClass",
fn: function () {
var obj = new withHiddenClass();
obj.timeout(1);
obj.url("google.com");
obj.type("get");
},
},
];
exports = module.exports = { cases };