@@ -15,53 +15,63 @@ export class VirtualizationComponent implements OnInit {
15
15
16
16
@ViewChild ( 'grid' )
17
17
public grid : GridComponent ;
18
- public ngOnInit ( ) : void { }
18
+ public date1 : number ;
19
+ public date2 : number ;
20
+ public flag : boolean = true ;
21
+ public ngOnInit ( ) : void { }
19
22
20
23
onClick = ( args : any ) => {
21
- for ( let i : number = 0 ; i < 100000 ; i ++ ) {
22
- if ( ! this . virtualData . length ) {
23
- this . show ( ) ;
24
+ this . show ( ) ;
25
+ if ( ! this . virtualData . length ) {
26
+ for ( let i : number = 0 ; i < 100000 ; i ++ ) {
27
+ this . virtualData . push ( {
28
+ 'FIELD1' : this . names [ Math . floor ( Math . random ( ) * this . names . length ) ] ,
29
+ 'FIELD2' : 1967 + ( i % 10 ) ,
30
+ 'FIELD3' : Math . floor ( Math . random ( ) * 200 ) ,
31
+ 'FIELD4' : Math . floor ( Math . random ( ) * 100 ) ,
32
+ 'FIELD5' : Math . floor ( Math . random ( ) * 2000 ) ,
33
+ 'FIELD6' : Math . floor ( Math . random ( ) * 1000 ) ,
34
+ 'FIELD7' : Math . floor ( Math . random ( ) * 100 ) ,
35
+ 'FIELD8' : Math . floor ( Math . random ( ) * 10 ) ,
36
+ 'FIELD9' : Math . floor ( Math . random ( ) * 10 ) ,
37
+ 'FIELD10' : Math . floor ( Math . random ( ) * 100 ) ,
38
+ 'FIELD11' : Math . floor ( Math . random ( ) * 100 ) ,
39
+ 'FIELD12' : Math . floor ( Math . random ( ) * 1000 ) ,
40
+ 'FIELD13' : Math . floor ( Math . random ( ) * 10 ) ,
41
+ 'FIELD14' : Math . floor ( Math . random ( ) * 10 ) ,
42
+ 'FIELD15' : Math . floor ( Math . random ( ) * 1000 ) ,
43
+ 'FIELD16' : Math . floor ( Math . random ( ) * 200 ) ,
44
+ 'FIELD17' : Math . floor ( Math . random ( ) * 300 ) ,
45
+ 'FIELD18' : Math . floor ( Math . random ( ) * 400 ) ,
46
+ 'FIELD19' : Math . floor ( Math . random ( ) * 500 ) ,
47
+ 'FIELD20' : Math . floor ( Math . random ( ) * 700 ) ,
48
+ 'FIELD21' : Math . floor ( Math . random ( ) * 800 ) ,
49
+ 'FIELD22' : Math . floor ( Math . random ( ) * 1000 ) ,
50
+ 'FIELD23' : Math . floor ( Math . random ( ) * 2000 ) ,
51
+ 'FIELD24' : Math . floor ( Math . random ( ) * 150 ) ,
52
+ 'FIELD25' : Math . floor ( Math . random ( ) * 1000 ) ,
53
+ 'FIELD26' : Math . floor ( Math . random ( ) * 100 ) ,
54
+ 'FIELD27' : Math . floor ( Math . random ( ) * 400 ) ,
55
+ 'FIELD28' : Math . floor ( Math . random ( ) * 600 ) ,
56
+ 'FIELD29' : Math . floor ( Math . random ( ) * 500 ) ,
57
+ 'FIELD30' : Math . floor ( Math . random ( ) * 300 ) ,
58
+ } ) ;
24
59
}
25
- this . virtualData . push ( {
26
- 'FIELD1' : this . names [ Math . floor ( Math . random ( ) * this . names . length ) ] ,
27
- 'FIELD2' : 1967 + ( i % 10 ) ,
28
- 'FIELD3' : Math . floor ( Math . random ( ) * 200 ) ,
29
- 'FIELD4' : Math . floor ( Math . random ( ) * 100 ) ,
30
- 'FIELD5' : Math . floor ( Math . random ( ) * 2000 ) ,
31
- 'FIELD6' : Math . floor ( Math . random ( ) * 1000 ) ,
32
- 'FIELD7' : Math . floor ( Math . random ( ) * 100 ) ,
33
- 'FIELD8' : Math . floor ( Math . random ( ) * 10 ) ,
34
- 'FIELD9' : Math . floor ( Math . random ( ) * 10 ) ,
35
- 'FIELD10' : Math . floor ( Math . random ( ) * 100 ) ,
36
- 'FIELD11' : Math . floor ( Math . random ( ) * 100 ) ,
37
- 'FIELD12' : Math . floor ( Math . random ( ) * 1000 ) ,
38
- 'FIELD13' : Math . floor ( Math . random ( ) * 10 ) ,
39
- 'FIELD14' : Math . floor ( Math . random ( ) * 10 ) ,
40
- 'FIELD15' : Math . floor ( Math . random ( ) * 1000 ) ,
41
- 'FIELD16' : Math . floor ( Math . random ( ) * 200 ) ,
42
- 'FIELD17' : Math . floor ( Math . random ( ) * 300 ) ,
43
- 'FIELD18' : Math . floor ( Math . random ( ) * 400 ) ,
44
- 'FIELD19' : Math . floor ( Math . random ( ) * 500 ) ,
45
- 'FIELD20' : Math . floor ( Math . random ( ) * 700 ) ,
46
- 'FIELD21' : Math . floor ( Math . random ( ) * 800 ) ,
47
- 'FIELD22' : Math . floor ( Math . random ( ) * 1000 ) ,
48
- 'FIELD23' : Math . floor ( Math . random ( ) * 2000 ) ,
49
- 'FIELD24' : Math . floor ( Math . random ( ) * 150 ) ,
50
- 'FIELD25' : Math . floor ( Math . random ( ) * 1000 ) ,
51
- 'FIELD26' : Math . floor ( Math . random ( ) * 100 ) ,
52
- 'FIELD27' : Math . floor ( Math . random ( ) * 400 ) ,
53
- 'FIELD28' : Math . floor ( Math . random ( ) * 600 ) ,
54
- 'FIELD29' : Math . floor ( Math . random ( ) * 500 ) ,
55
- 'FIELD30' : Math . floor ( Math . random ( ) * 300 ) ,
56
- } ) ;
60
+ this . grid . dataSource = this . virtualData ;
57
61
}
58
- this . grid . dataSource = this . virtualData ;
62
+ this . flag = true ;
63
+ this . date1 = new Date ( ) . getTime ( ) ;
59
64
this . grid . refresh ( ) ;
60
65
}
61
66
show ( ) : void {
62
67
document . getElementById ( 'popup' ) . style . display = 'inline-block' ;
63
68
}
64
69
hide ( ) : void {
70
+ if ( this . flag && this . date1 ) {
71
+ this . date2 = new Date ( ) . getTime ( ) ;
72
+ document . getElementById ( 'performanceTime' ) . innerHTML = 'Time Taken: ' + ( this . date2 - this . date1 ) + 'ms' ;
73
+ this . flag = false ;
74
+ }
65
75
document . getElementById ( 'popup' ) . style . display = 'none' ;
66
76
}
67
77
}
0 commit comments