|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60055 - in sandbox/statistics/detail/assign: boost/assign/auto_size/array libs/assign/test
From: erwann.rogard_at_[hidden]
Date: 2010-03-01 15:24:39
Author: e_r
Date: 2010-03-01 15:24:38 EST (Mon, 01 Mar 2010)
New Revision: 60055
URL: http://svn.boost.org/trac/boost/changeset/60055
Log:
m
Text files modified:
sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp | 3 +
sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp | 56 ++++++++++++++++++++++++++++++++++++++++
sandbox/statistics/detail/assign/libs/assign/test/speed_common.h | 31 ++++++++++++++++++++-
3 files changed, 87 insertions(+), 3 deletions(-)
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/array/wrapper.hpp 2010-03-01 15:24:38 EST (Mon, 01 Mar 2010)
@@ -24,7 +24,6 @@
{
typedef typename auto_size::ref_array<T,N,Ref>::type ref_array_;
- typedef boost::shared_ptr<ref_array_> smart_ptr_;
public:
@@ -42,6 +41,8 @@
void initialize(const E& coll)const{
write_to_array(this->ref_array,coll);
}
+
+ mutable ref_array_ ref_array;
};
Modified: sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed_common.cpp 2010-03-01 15:24:38 EST (Mon, 01 Mar 2010)
@@ -2,6 +2,13 @@
// test::speed_common.cpp //
// //
//////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2010 Manuel Peinado Gallego
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+///////////////////////////////////////////////////////////////////////////////
+#include <ctime>
#include <algorithm>
#include <string>
#include <vector>
@@ -49,3 +56,52 @@
);
return result;
}
+
+namespace mpg
+{
+ namespace detail
+ {
+ double clock_diff_to_sec(long clock_diff)
+ {
+ return double(clock_diff) / CLOCKS_PER_SEC;
+ }
+
+ template<class Proc>
+ double time_it_impl(Proc proc, int N=1) // returns time in microseconds
+ {
+ std::clock_t const start = std::clock();
+ for(int i = 0; i < N; ++i)
+ proc();
+ std::clock_t const end = std::clock();
+ if(clock_diff_to_sec(end - start) < .2)
+ return time_it_impl(proc, N * 5);
+ return clock_diff_to_sec(end - start) * (1e6 / N);
+ }
+
+ template<class Proc, class Result>
+ double time_it_impl(Proc proc, Result & result, int N=1) // returns time in microseconds
+ {
+ std::clock_t const start = std::clock();
+ for(int i = 0; i < N; ++i)
+ result = proc();
+ std::clock_t const end = std::clock();
+ if(clock_diff_to_sec(end - start) < .2)
+ return time_it_impl(proc, result, N * 5);
+ return clock_diff_to_sec(end - start) * (1e6 / N);
+ }
+ }
+
+ template<class Proc>
+ double time_it(Proc proc) // returns time in microseconds
+ {
+ return detail::time_it_impl(proc, 1);
+ }
+
+ template<class Proc, class Result>
+ double time_it(Proc proc, Result & result) // returns time in microseconds
+ {
+ return detail::time_it_impl(proc, result, 1);
+ }
+}
+
+
Modified: sandbox/statistics/detail/assign/libs/assign/test/speed_common.h
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed_common.h (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed_common.h 2010-03-01 15:24:38 EST (Mon, 01 Mar 2010)
@@ -2,8 +2,14 @@
// test::speed_common.h //
// //
//////////////////////////////////////////////////////////////////////////////
-#ifndef LIBS_ASSIGN_TEST_SPEED_COMMON_CSV_ER_2010_H
-#define LIBS_ASSIGN_TEST_SPEED_COMMON_CSV_ER_2010_H
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2010 Manuel Peinado Gallego
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_ASSIGN_TEST_SPEED_COMMON_ER_2010_H
+#define LIBS_ASSIGN_TEST_SPEED_COMMON_ER_2010_H
#include <vector>
#include <string>
@@ -13,4 +19,25 @@
std::string rand_str(int len);
std::vector<int> rand_vec(int);
+namespace mpg
+{
+ namespace detail
+ {
+ double clock_diff_to_sec(long clock_diff);
+
+ template<class Proc>
+ double time_it_impl(Proc proc, int N=1);
+
+ template<class Proc, class Result>
+ double time_it_impl(Proc proc, Result & result, int N=1);
+ }
+
+ template<class Proc>
+ double time_it(Proc proc);
+
+ template<class Proc, class Result>
+ double time_it(Proc proc, Result & result);
+}
+
+
#endif
\ No newline at end of file
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