Chris@1622
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1622
|
2
|
Chris@1622
|
3 /*
|
Chris@1622
|
4 Sonic Visualiser
|
Chris@1622
|
5 An audio file viewer and annotation editor.
|
Chris@1622
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1622
|
7
|
Chris@1622
|
8 This program is free software; you can redistribute it and/or
|
Chris@1622
|
9 modify it under the terms of the GNU General Public License as
|
Chris@1622
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@1622
|
11 License, or (at your option) any later version. See the file
|
Chris@1622
|
12 COPYING included with this distribution for more information.
|
Chris@1622
|
13 */
|
Chris@1622
|
14
|
Chris@1622
|
15 #ifndef STRESS_EVENT_SERIES_H
|
Chris@1622
|
16 #define STRESS_EVENT_SERIES_H
|
Chris@1622
|
17
|
Chris@1622
|
18 #include "../EventSeries.h"
|
Chris@1622
|
19
|
Chris@1622
|
20 #include <QObject>
|
Chris@1622
|
21 #include <QtTest>
|
Chris@1622
|
22
|
Chris@1622
|
23 #include <iostream>
|
Chris@1622
|
24
|
Chris@1622
|
25 using namespace std;
|
Chris@1622
|
26
|
Chris@1622
|
27 class StressEventSeries : public QObject
|
Chris@1622
|
28 {
|
Chris@1622
|
29 Q_OBJECT
|
Chris@1622
|
30
|
Chris@1622
|
31 private:
|
Chris@1622
|
32 void report(int n, QString sort, clock_t start, clock_t end) {
|
Chris@1622
|
33 QString message = QString("Time for %1 %2 events = ").arg(n).arg(sort);
|
Chris@1622
|
34 cerr << " " << message;
|
Chris@1622
|
35 for (int i = 0; i < 34 - message.size(); ++i) cerr << " ";
|
Chris@1622
|
36 cerr << double(end - start) * 1000.0 / double(CLOCKS_PER_SEC)
|
Chris@1622
|
37 << "ms" << endl;
|
Chris@1622
|
38 }
|
Chris@1622
|
39
|
Chris@1622
|
40 void short_n(int n) {
|
Chris@1622
|
41 clock_t start = clock();
|
Chris@1622
|
42 EventSeries s;
|
Chris@1622
|
43 for (int i = 0; i < n; ++i) {
|
Chris@1622
|
44 float value = float(rand()) / float(RAND_MAX);
|
Chris@1622
|
45 Event e(rand(), value, 1000, QString("event %1").arg(i));
|
Chris@1622
|
46 s.add(e);
|
Chris@1622
|
47 }
|
Chris@1622
|
48 QCOMPARE(s.count(), n);
|
Chris@1622
|
49 clock_t end = clock();
|
Chris@1622
|
50 report(n, "short", start, end);
|
Chris@1622
|
51 }
|
Chris@1622
|
52
|
Chris@1622
|
53 void longish_n(int n) {
|
Chris@1622
|
54 clock_t start = clock();
|
Chris@1622
|
55 EventSeries s;
|
Chris@1622
|
56 for (int i = 0; i < n; ++i) {
|
Chris@1622
|
57 float value = float(rand()) / float(RAND_MAX);
|
Chris@1622
|
58 Event e(rand(), value, rand() / 1000, QString("event %1").arg(i));
|
Chris@1622
|
59 s.add(e);
|
Chris@1622
|
60 }
|
Chris@1622
|
61 QCOMPARE(s.count(), n);
|
Chris@1622
|
62 clock_t end = clock();
|
Chris@1622
|
63 report(n, "longish", start, end);
|
Chris@1622
|
64 }
|
Chris@1622
|
65
|
Chris@1622
|
66 private slots:
|
Chris@1622
|
67 void short_3() { short_n(1000); }
|
Chris@1622
|
68 void short_4() { short_n(10000); }
|
Chris@1622
|
69 void short_5() { short_n(100000); }
|
Chris@1622
|
70 void short_6() { short_n(1000000); }
|
Chris@1622
|
71 void longish_3() { longish_n(1000); }
|
Chris@1622
|
72 void longish_4() { longish_n(10000); }
|
Chris@1622
|
73 void longish_5() { longish_n(100000); }
|
Chris@1622
|
74
|
Chris@1625
|
75 /*
|
Chris@1625
|
76
|
Chris@1625
|
77 cf5196881e3e:
|
Chris@1622
|
78
|
Chris@1622
|
79 Time for 1000 short events = 1.169ms
|
Chris@1622
|
80 Time for 10000 short events = 20.566ms
|
Chris@1622
|
81 Time for 100000 short events = 279.242ms
|
Chris@1622
|
82 Time for 1000000 short events = 3925.06ms
|
Chris@1622
|
83 Time for 1000 longish events = 1.938ms
|
Chris@1622
|
84 Time for 10000 longish events = 72.209ms
|
Chris@1622
|
85 Time for 100000 longish events = 6469.26ms
|
Chris@1622
|
86
|
Chris@1622
|
87 Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 12785ms
|
Chris@1622
|
88
|
Chris@1622
|
89 13.40user 0.37system 0:13.84elapsed 99%CPU (0avgtext+0avgdata 1052000maxresident)k
|
Chris@1622
|
90 0inputs+40outputs (0major+260249minor)pagefaults 0swaps
|
Chris@1625
|
91
|
Chris@1625
|
92
|
Chris@1625
|
93 dcd510bd89db:
|
Chris@1625
|
94
|
Chris@1625
|
95 Time for 1000 short events = 1.824ms
|
Chris@1625
|
96 Time for 10000 short events = 19.203ms
|
Chris@1625
|
97 Time for 100000 short events = 270.631ms
|
Chris@1625
|
98 Time for 1000000 short events = 4425.2ms
|
Chris@1625
|
99 Time for 1000 longish events = 2.395ms
|
Chris@1625
|
100 Time for 10000 longish events = 83.623ms
|
Chris@1625
|
101 Time for 100000 longish events = 5958.28ms
|
Chris@1625
|
102
|
Chris@1625
|
103 Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 13116ms
|
Chris@1625
|
104
|
Chris@1625
|
105 13.64user 0.26system 0:13.98elapsed 99%CPU (0avgtext+0avgdata 948104maxresident)k
|
Chris@1625
|
106 0inputs+40outputs (0major+234387minor)pagefaults 0swaps
|
Chris@1625
|
107
|
Chris@1627
|
108 895186c43fce:
|
Chris@1627
|
109
|
Chris@1627
|
110 Time for 1000 short events = 1.706ms
|
Chris@1627
|
111 Time for 10000 short events = 23.192ms
|
Chris@1627
|
112 Time for 100000 short events = 310.605ms
|
Chris@1627
|
113 Time for 1000000 short events = 4675.7ms
|
Chris@1627
|
114 Time for 1000 longish events = 2.186ms
|
Chris@1627
|
115 Time for 10000 longish events = 760.659ms
|
Chris@1627
|
116 Time for 100000 longish events = 1335.57ms
|
Chris@1627
|
117
|
Chris@1627
|
118 Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 7804ms
|
Chris@1627
|
119
|
Chris@1627
|
120 7.97user 0.29system 0:08.31elapsed 99%CPU (0avgtext+0avgdata 706388maxresident)k
|
Chris@1627
|
121 0inputs+40outputs (0major+182225minor)pagefaults 0swaps
|
Chris@1627
|
122
|
Chris@1622
|
123 */
|
Chris@1622
|
124 };
|
Chris@1622
|
125
|
Chris@1622
|
126 #endif
|