-
Notifications
You must be signed in to change notification settings - Fork 5
/
test4.ts
31 lines (25 loc) · 795 Bytes
/
test4.ts
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
module Test {
export class test4 {
public constructor() {
}
public start(): void {
var arr1: Array<number> = [];
var a: string;
var i: number;
for (i = 0; i < 100000; i++) {
arr1.push(i);
}
var ctime1: number = new Date().getTime();
for (i = 0; i < arr1.length; i++) {
a = i.toString();
}
console.log(new Date().getTime() - ctime1);//ºÄʱ£º47
var ctime2: number = new Date().getTime();
var length: number = arr1.length;
for (i = 0; i < length; ++i) {
a = i.toString();
}
console.log(new Date().getTime() - ctime2);//ºÄʱ£º38
}
}
}