Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/Lock.cpp')
-rw-r--r--src/tests/Lock.cpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/tests/Lock.cpp b/src/tests/Lock.cpp
index 22b83d0ea..48edf602b 100644
--- a/src/tests/Lock.cpp
+++ b/src/tests/Lock.cpp
@@ -12,14 +12,14 @@
// one timeslice.
#define ITER 100000000
-typedef QPair<quint64,int> tr;
+typedef QPair< quint64, int > tr;
class SillyLock {
- public:
- int counter;
- SillyLock();
- void lock();
- void unlock();
+public:
+ int counter;
+ SillyLock();
+ void lock();
+ void unlock();
};
SillyLock::SillyLock() {
@@ -41,11 +41,11 @@ void SillyLock::unlock() {
}
class PosixLock {
- public:
- pthread_mutex_t m;
- PosixLock();
- void lock();
- void unlock();
+public:
+ pthread_mutex_t m;
+ PosixLock();
+ void lock();
+ void unlock();
};
PosixLock::PosixLock() {
@@ -60,23 +60,21 @@ void PosixLock::unlock() {
pthread_mutex_unlock(&m);
}
-template<class T>
-class SpeedTest {
- public:
- T &lock;
+template< class T > class SpeedTest {
+public:
+ T &lock;
- SpeedTest(T &l) : lock(l) {
- }
+ SpeedTest(T &l) : lock(l) {}
- quint64 test() {
- Timer t;
- t.restart();
- for (int i=0;i<ITER;i++) {
- lock.lock();
- lock.unlock();
- }
- return t.elapsed();
+ quint64 test() {
+ Timer t;
+ t.restart();
+ for (int i = 0; i < ITER; i++) {
+ lock.lock();
+ lock.unlock();
}
+ return t.elapsed();
+ }
};
int main(int argc, char **argv) {
@@ -87,10 +85,10 @@ int main(int argc, char **argv) {
SillyLock sl;
PosixLock pl;
- SpeedTest<QMutex> stqm(qm);
- SpeedTest<QMutex> stqmr(qmr);
- SpeedTest<SillyLock> stsl(sl);
- SpeedTest<PosixLock> stpl(pl);
+ SpeedTest< QMutex > stqm(qm);
+ SpeedTest< QMutex > stqmr(qmr);
+ SpeedTest< SillyLock > stsl(sl);
+ SpeedTest< PosixLock > stpl(pl);
quint64 elapsed;