Skip to content

Commit 0e57d5f

Browse files
authored
adding test files
1 parent 4872c5a commit 0e57d5f

12 files changed

+531
-1
lines changed

Diff for: class-objects.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ <h1>Objects created with class</h1>
3636
<img src="./images/class-objects.png" alt="" />
3737
</div>
3838
</body>
39-
</html>
39+
</html>

Diff for: class-objects.js

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
class JsClass {
2+
text1() {
3+
const str1 = "this1 is a lorem ipsum string";
4+
const str2 = "this1 is not a lorem ipsum string";
5+
const str3 = "this1 is not a lorem ipsum string2";
6+
const str4 = "this1 is not a lorem ipsum string4";
7+
const str5 = "this1 is not a lorem ipsum string5";
8+
const str6 = "this1 is not a lorem ipsum string6";
9+
return str1 + str2 + str3 + str4 + str5 + str6;
10+
}
11+
text2() {
12+
const str1 = "this2 is a lorem ipsum string";
13+
const str2 = "this2 is not a lorem ipsum string";
14+
const str3 = "this2 is not a lorem ipsum string2";
15+
const str4 = "this2 is not a lorem ipsum string4";
16+
const str5 = "this2 is not a lorem ipsum string5";
17+
const str6 = "this2 is not a lorem ipsum string6";
18+
return str1 + str2 + str3 + str4 + str5 + str6;
19+
}
20+
text3() {
21+
const str1 = "this3 is a lorem ipsum string";
22+
const str2 = "this3 is not a lorem ipsum string";
23+
const str3 = "this3 is not a lorem ipsum string2";
24+
const str4 = "this3 is not a lorem ipsum string4";
25+
const str5 = "this3 is not a lorem ipsum string5";
26+
const str6 = "this3 is not a lorem ipsum string6";
27+
return str1 + str2 + str3 + str4 + str5 + str6;
28+
}
29+
text4() {
30+
const str1 = "this4 is a lorem ipsum string";
31+
const str2 = "this4 is not a lorem ipsum string";
32+
const str3 = "this4 is not a lorem ipsum string2";
33+
const str4 = "this4 is not a lorem ipsum string4";
34+
const str5 = "this4 is not a lorem ipsum string5";
35+
const str6 = "this4 is not a lorem ipsum string6";
36+
return str1 + str2 + str3 + str4 + str5 + str6;
37+
}
38+
text5() {
39+
const str1 = "this5 is a lorem ipsum string";
40+
const str2 = "this5 is not a lorem ipsum string";
41+
const str3 = "this5 is not a lorem ipsum string2";
42+
const str4 = "this5 is not a lorem ipsum string4";
43+
const str5 = "this5 is not a lorem ipsum string5";
44+
const str6 = "this5 is not a lorem ipsum string6";
45+
return str1 + str2 + str3 + str4 + str5 + str6;
46+
}
47+
text6() {
48+
const str1 = "this6 is a lorem ipsum string";
49+
const str2 = "this6 is not a lorem ipsum string";
50+
const str3 = "this6 is not a lorem ipsum string2";
51+
const str4 = "this6 is not a lorem ipsum string4";
52+
const str5 = "this6 is not a lorem ipsum string5";
53+
const str6 = "this6 is not a lorem ipsum string6";
54+
return str1 + str2 + str3 + str4 + str5 + str6;
55+
}
56+
text7() {
57+
const str1 = "this7 is a lorem ipsum string";
58+
const str2 = "this7 is not a lorem ipsum string";
59+
const str3 = "this7 is not a lorem ipsum string2";
60+
const str4 = "this7 is not a lorem ipsum string4";
61+
const str5 = "this7 is not a lorem ipsum string5";
62+
const str6 = "this7 is not a lorem ipsum string6";
63+
return str1 + str2 + str3 + str4 + str5 + str6;
64+
}
65+
text8() {
66+
const str1 = "this8 is a lorem ipsum string";
67+
const str2 = "this8 is not a lorem ipsum string";
68+
const str3 = "this8 is not a lorem ipsum string2";
69+
const str4 = "this8 is not a lorem ipsum string4";
70+
const str5 = "this8 is not a lorem ipsum string5";
71+
const str6 = "this8 is not a lorem ipsum string6";
72+
return str1 + str2 + str3 + str4 + str5 + str6;
73+
}
74+
text9() {
75+
const str1 = "this9 is a lorem ipsum string";
76+
const str2 = "this9 is not a lorem ipsum string";
77+
const str3 = "this9 is not a lorem ipsum string2";
78+
const str4 = "this9 is not a lorem ipsum string4";
79+
const str5 = "this9 is not a lorem ipsum string5";
80+
const str6 = "this9 is not a lorem ipsum string6";
81+
return str1 + str2 + str3 + str4 + str5 + str6;
82+
}
83+
text10() {
84+
const str1 = "this is a lorem ipsum string";
85+
const str2 = "this is not a lorem ipsum string";
86+
const str3 = "this is not a lorem ipsum string2";
87+
const str4 = "this is not a lorem ipsum string4";
88+
const str5 = "this is not a lorem ipsum string5";
89+
const str6 = "this is not a lorem ipsum string6";
90+
return str1 + str2 + str3 + str4 + str5 + str6;
91+
}
92+
}
93+
94+
const jsObjs = [];
95+
for (let i = 0; i < 1_0_00_000; i++) {
96+
const jsObj = new JsClass();
97+
jsObjs.push(jsObj);
98+
}
99+
100+
console.log("Objects created with class. Total objects\t", jsObjs.length);

Diff for: function-objects.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Function objects</title>
5+
<style>
6+
body {
7+
max-width: 600px;
8+
margin: auto;
9+
}
10+
nav {
11+
display: flex;
12+
justify-content: space-evenly;
13+
padding-top: 20px;
14+
}
15+
h1 {
16+
text-align: center;
17+
}
18+
.block {
19+
text-align: center;
20+
}
21+
img {
22+
width: 100%;
23+
}
24+
</style>
25+
<script src="function-objects.js" type="text/javascript"></script>
26+
</head>
27+
<body>
28+
<nav>
29+
<a href="class-objects.html">Class objects</a>
30+
<a href="function-objects.html">Function objects</a>
31+
<a href="multi-class-objects.html">Multiple class objects</a>
32+
</nav>
33+
<div class="block">
34+
<h1>Objects created with function</h1>
35+
<p>Total Objects: 10_000_00 (1 million)</p>
36+
<img src="./images/function-objects.png" alt="" />
37+
</div>
38+
</body>
39+
</html>

Diff for: function-objects.js

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
function text1() {
2+
const str1 = "this1 is a lorem ipsum string";
3+
const str2 = "this1 is not a lorem ipsum string";
4+
const str3 = "this1 is not a lorem ipsum string2";
5+
const str4 = "this1 is not a lorem ipsum string4";
6+
const str5 = "this1 is not a lorem ipsum string5";
7+
const str6 = "this1 is not a lorem ipsum string6";
8+
return str1 + str2 + str3 + str4 + str5 + str6;
9+
}
10+
11+
function text2() {
12+
const str1 = "this2 is a lorem ipsum string";
13+
const str2 = "this2 is not a lorem ipsum string";
14+
const str3 = "this2 is not a lorem ipsum string2";
15+
const str4 = "this2 is not a lorem ipsum string4";
16+
const str5 = "this2 is not a lorem ipsum string5";
17+
const str6 = "this2 is not a lorem ipsum string6";
18+
return str1 + str2 + str3 + str4 + str5 + str6;
19+
}
20+
21+
function text3() {
22+
const str1 = "this3 is a lorem ipsum string";
23+
const str2 = "this3 is not a lorem ipsum string";
24+
const str3 = "this3 is not a lorem ipsum string2";
25+
const str4 = "this3 is not a lorem ipsum string4";
26+
const str5 = "this3 is not a lorem ipsum string5";
27+
const str6 = "this3 is not a lorem ipsum string6";
28+
return str1 + str2 + str3 + str4 + str5 + str6;
29+
}
30+
31+
function text4() {
32+
const str1 = "this4 is a lorem ipsum string";
33+
const str2 = "this4 is not a lorem ipsum string";
34+
const str3 = "this4 is not a lorem ipsum string2";
35+
const str4 = "this4 is not a lorem ipsum string4";
36+
const str5 = "this4 is not a lorem ipsum string5";
37+
const str6 = "this4 is not a lorem ipsum string6";
38+
return str1 + str2 + str3 + str4 + str5 + str6;
39+
}
40+
41+
function text5() {
42+
const str1 = "this5 is a lorem ipsum string";
43+
const str2 = "this5 is not a lorem ipsum string";
44+
const str3 = "this5 is not a lorem ipsum string2";
45+
const str4 = "this5 is not a lorem ipsum string4";
46+
const str5 = "this5 is not a lorem ipsum string5";
47+
const str6 = "this5 is not a lorem ipsum string6";
48+
return str1 + str2 + str3 + str4 + str5 + str6;
49+
}
50+
51+
function text6() {
52+
const str1 = "this6 is a lorem ipsum string";
53+
const str2 = "this6 is not a lorem ipsum string";
54+
const str3 = "this6 is not a lorem ipsum string2";
55+
const str4 = "this6 is not a lorem ipsum string4";
56+
const str5 = "this6 is not a lorem ipsum string5";
57+
const str6 = "this6 is not a lorem ipsum string6";
58+
return str1 + str2 + str3 + str4 + str5 + str6;
59+
}
60+
61+
function text7() {
62+
const str1 = "this7 is a lorem ipsum string";
63+
const str2 = "this7 is not a lorem ipsum string";
64+
const str3 = "this7 is not a lorem ipsum string2";
65+
const str4 = "this7 is not a lorem ipsum string4";
66+
const str5 = "this7 is not a lorem ipsum string5";
67+
const str6 = "this7 is not a lorem ipsum string6";
68+
return str1 + str2 + str3 + str4 + str5 + str6;
69+
}
70+
71+
function text8() {
72+
const str1 = "this8 is a lorem ipsum string";
73+
const str2 = "this8 is not a lorem ipsum string";
74+
const str3 = "this8 is not a lorem ipsum string2";
75+
const str4 = "this8 is not a lorem ipsum string4";
76+
const str5 = "this8 is not a lorem ipsum string5";
77+
const str6 = "this8 is not a lorem ipsum string6";
78+
return str1 + str2 + str3 + str4 + str5 + str6;
79+
}
80+
81+
function text9() {
82+
const str1 = "this9 is a lorem ipsum string";
83+
const str2 = "this9 is not a lorem ipsum string";
84+
const str3 = "this9 is not a lorem ipsum string2";
85+
const str4 = "this9 is not a lorem ipsum string4";
86+
const str5 = "this9 is not a lorem ipsum string5";
87+
const str6 = "this9 is not a lorem ipsum string6";
88+
return str1 + str2 + str3 + str4 + str5 + str6;
89+
}
90+
91+
function text10() {
92+
const str1 = "this10 is a lorem ipsum string";
93+
const str2 = "this10 is not a lorem ipsum string";
94+
const str3 = "this10 is not a lorem ipsum string2";
95+
const str4 = "this10 is not a lorem ipsum string4";
96+
const str5 = "this10 is not a lorem ipsum string5";
97+
const str6 = "this10 is not a lorem ipsum string6";
98+
return str1 + str2 + str3 + str4 + str5 + str6;
99+
}
100+
101+
const jsObjs = [];
102+
103+
for (let i = 0; i < 1_00_000; i++) {
104+
const jsObj = new text1();
105+
jsObjs.push(jsObj);
106+
}
107+
for (let i = 0; i < 1_00_000; i++) {
108+
const jsObj = new text2();
109+
jsObjs.push(jsObj);
110+
}
111+
for (let i = 0; i < 1_00_000; i++) {
112+
const jsObj = new text3();
113+
jsObjs.push(jsObj);
114+
}
115+
for (let i = 0; i < 1_00_000; i++) {
116+
const jsObj = new text4();
117+
jsObjs.push(jsObj);
118+
}
119+
for (let i = 0; i < 1_00_000; i++) {
120+
const jsObj = new text5();
121+
jsObjs.push(jsObj);
122+
}
123+
for (let i = 0; i < 1_00_000; i++) {
124+
const jsObj = new text6();
125+
jsObjs.push(jsObj);
126+
}
127+
for (let i = 0; i < 1_00_000; i++) {
128+
const jsObj = new text7();
129+
jsObjs.push(jsObj);
130+
}
131+
for (let i = 0; i < 1_00_000; i++) {
132+
const jsObj = new text8();
133+
jsObjs.push(jsObj);
134+
}
135+
for (let i = 0; i < 1_00_000; i++) {
136+
const jsObj = new text9();
137+
jsObjs.push(jsObj);
138+
}
139+
140+
for (let i = 0; i < 1_00_000; i++) {
141+
const jsObj = new text10();
142+
jsObjs.push(jsObj);
143+
}
144+
145+
console.log("Objects created with function. Total function objects\t", jsObjs.length);

Diff for: images/class-objects.png

108 KB
Loading

Diff for: images/function-objects.png

104 KB
Loading

Diff for: images/js-objects.png

862 KB
Loading

Diff for: images/multi-class-objects.png

90.4 KB
Loading

Diff for: index.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
body {
6+
width: 600px;
7+
margin: auto;
8+
}
9+
</style>
10+
</head>
11+
<body>
12+
<h1>Memory comparison with js objects</h1>
13+
<ul>
14+
<li>
15+
<a href="class-objects.html">Class Objects</a>
16+
</li>
17+
<li>
18+
<a href="function-objects.html">Function Objects</a>
19+
</li>
20+
<li>
21+
<a href="multi-class-objects.html">Multi class objects</a>
22+
</li>
23+
</ul>
24+
</body>
25+
</html>

Diff for: multi-class-objects.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Multi class Objects</title>
5+
<style>
6+
body {
7+
max-width: 600px;
8+
margin: auto;
9+
}
10+
nav {
11+
display: flex;
12+
justify-content: space-evenly;
13+
padding-top: 20px;
14+
}
15+
h1 {
16+
text-align: center;
17+
}
18+
.block {
19+
text-align: center;
20+
}
21+
img {
22+
width: 100%;
23+
}
24+
</style>
25+
<script src="multi-class-objects.js" type="text/javascript"></script>
26+
</head>
27+
<body>
28+
<nav>
29+
<a href="class-objects.html">Class objects</a>
30+
<a href="function-objects.html">Function objects</a>
31+
<a href="multi-class-objects.html">Multiple class objects</a>
32+
</nav>
33+
<div class="block">
34+
<h1>Objects created with multiple classes</h1>
35+
<p>Total Objects: 10_000_00 (1 million)</p>
36+
<img src="./images/multi-class-objects.png" alt="" />
37+
</div>
38+
</body>
39+
</html>

0 commit comments

Comments
 (0)