|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72236 - sandbox/block_ptr/libs/smart_ptr/example
From: phil_at_[hidden]
Date: 2011-05-27 18:40:17
Author: pbouchard
Date: 2011-05-27 18:40:16 EDT (Fri, 27 May 2011)
New Revision: 72236
URL: http://svn.boost.org/trac/boost/changeset/72236
Log:
* Code cleanup
Text files modified:
sandbox/block_ptr/libs/smart_ptr/example/benchmark.cpp | 34 +++++++++++-----------------------
1 files changed, 11 insertions(+), 23 deletions(-)
Modified: sandbox/block_ptr/libs/smart_ptr/example/benchmark.cpp
==============================================================================
--- sandbox/block_ptr/libs/smart_ptr/example/benchmark.cpp (original)
+++ sandbox/block_ptr/libs/smart_ptr/example/benchmark.cpp 2011-05-27 18:40:16 EDT (Fri, 27 May 2011)
@@ -51,26 +51,14 @@
timespec diff(timespec start, timespec end);
-int cpu_bind(const unsigned short cpu)
-{
- cpu_set_t mask;
- int ret;
-
- CPU_ZERO(&mask);
- CPU_SET((int)cpu, &mask);
- ret = sched_setaffinity(0, sizeof mask, &mask);
-
- return ret;
-}
-
int main(int argc, char* argv[])
{
- cpu_bind(0);
-
timespec ts[2];
- long median[5][3];
+
+ const int n = 5;
+ long median[n][3];
- for (int i = 0; i < 5; ++ i)
+ for (int i = 0; i < n; ++ i)
{
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, & ts[0]);
worker_make< auto_ptr<int>, make_auto<int> >();
@@ -89,12 +77,12 @@
}
cout << "make:" << endl;
- cout << "auto_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[3][0] << " ns" << endl;
- cout << "shared_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[3][1] << " ns" << endl;
- cout << "block_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[3][2] << " ns" << endl;
+ cout << "auto_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[n/2+1][0] << " ns" << endl;
+ cout << "shared_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[n/2+1][1] << " ns" << endl;
+ cout << "block_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[n/2+1][2] << " ns" << endl;
cout << endl;
- for (int i = 0; i < 5; ++ i)
+ for (int i = 0; i < n; ++ i)
{
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, & ts[0]);
worker_new< auto_ptr<int>, int >();
@@ -113,9 +101,9 @@
}
cout << "new:" << endl;
- cout << "auto_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[3][0] << " ns" << endl;
- cout << "shared_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[3][1] << " ns" << endl;
- cout << "block_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[3][2] << " ns" << endl;
+ cout << "auto_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[n/2+1][0] << " ns" << endl;
+ cout << "shared_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[n/2+1][1] << " ns" << endl;
+ cout << "block_ptr:\t" << setw(numeric_limits<long>::digits10 + 2) << median[n/2+1][2] << " ns" << endl;
cout << endl;
return 0;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk