Line | |
---|
1 | #include "Pvs.h"
|
---|
2 | #include "Timer/PerfTimer.h"
|
---|
3 | #include "common.h"
|
---|
4 | #include <iostream>
|
---|
5 |
|
---|
6 |
|
---|
7 | namespace CHCDemoEngine
|
---|
8 | {
|
---|
9 |
|
---|
10 | void TestPvsPerformance()
|
---|
11 | {
|
---|
12 | // Pvs pvs(15000);
|
---|
13 | const int prange=10000;
|
---|
14 | Pvs pvs[prange+1];
|
---|
15 | // test PVS performance
|
---|
16 | const int num = 100000000;
|
---|
17 | const int range = 50000;
|
---|
18 | PerfTimer timer;
|
---|
19 | timer.Entry();
|
---|
20 |
|
---|
21 | for (int i=0; i < num; i++)
|
---|
22 | {
|
---|
23 | int id = (int)Random(range);
|
---|
24 | int pid = (5*num)%prange;
|
---|
25 | pvs[pid].Insert(id, (float)i);
|
---|
26 | if (i%1000000 == 0) {
|
---|
27 | cout<<i/1000000<<" M"<<endl;
|
---|
28 | cout<<"size = "<<pvs[pid].GetSize()/(1000*1000)<<"M"<<endl;
|
---|
29 | // cout << "bucket_count: " << pvs.entries.bucket_count() << endl;
|
---|
30 | }
|
---|
31 | }
|
---|
32 | timer.Exit();
|
---|
33 |
|
---|
34 |
|
---|
35 | cout<<"Pvs insert speed = "<<num/float(1000*1000*timer.TotalTime())<<
|
---|
36 | "M entries/s\n";
|
---|
37 | cout<<"Memory usage "<<pvs[0].GetMemoryUsage()<<" bytes"<<endl;
|
---|
38 |
|
---|
39 | int counter = 0;
|
---|
40 | timer.Entry();
|
---|
41 | PvsIterator it(pvs[0]);
|
---|
42 | for (; it.HasMoreEntries(); it.Next())
|
---|
43 | {
|
---|
44 | ++ counter;
|
---|
45 | }
|
---|
46 | timer.Exit();
|
---|
47 |
|
---|
48 | cout<<"Pvs count = "<<counter<<endl;
|
---|
49 | cout<<"Pvs iteration speed = "<<pvs[0].GetSize()/float(1000*1000*timer.TotalTime())<<
|
---|
50 | "M entries/s\n";
|
---|
51 |
|
---|
52 | counter = 0;
|
---|
53 | timer.Entry();
|
---|
54 | PvsTimeIterator tit(pvs[0], 400);
|
---|
55 | for (; tit.HasMoreEntries(); tit.Next()) {
|
---|
56 | counter++;
|
---|
57 | }
|
---|
58 | timer.Exit();
|
---|
59 | cout<<"Pvs time count = "<<counter<<endl;
|
---|
60 | cout<<"Pvs iteration speed = "<<pvs[0].GetSize()/(1024*1024*timer.TotalTime())<<
|
---|
61 | "M entries/s\n";
|
---|
62 | }
|
---|
63 |
|
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.