|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74651 - trunk/libs/chrono/perf
From: vicente.botet_at_[hidden]
Date: 2011-10-02 12:27:16
Author: viboes
Date: 2011-10-02 12:27:15 EDT (Sun, 02 Oct 2011)
New Revision: 74651
URL: http://svn.boost.org/trac/boost/changeset/74651
Log:
Chrono: Added perf for now function
Added:
trunk/libs/chrono/perf/
trunk/libs/chrono/perf/Jamfile.v2 (contents, props changed)
trunk/libs/chrono/perf/store_now_in_vector.cpp (contents, props changed)
Added: trunk/libs/chrono/perf/Jamfile.v2
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/perf/Jamfile.v2 2011-10-02 12:27:15 EDT (Sun, 02 Oct 2011)
@@ -0,0 +1,168 @@
+# Boost Chrono Library test Jamfile
+
+# Copyright Beman Dawes 2008
+# Copyright Vicente J. Botet Escriba 2009-2010
+
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
+
+# See library home page at http://www.boost.org/libs/chrono
+
+import os ;
+import feature ;
+
+project
+ : requirements
+ <target-os>freebsd:<threading>multi
+ <target-os>linux:<threading>multi
+ <toolset>pgi:<threading>multi
+ <toolset>msvc:<asynch-exceptions>on
+ <define>BOOST_CHRONO_USES_MPL_ASSERT
+ <define>BOOST_SYSTEM_NO_DEPRECATED
+ <toolset>sun:<define>BOOST_TYPEOF_EMULATION
+ <warnings>all
+ <toolset>gcc:<cxxflags>-Wextra
+ <toolset>gcc:<cxxflags>-pedantic
+ <toolset>gcc:<cxxflags>-Wno-long-long
+ <toolset>darwin:<cxxflags>-Wextra
+ <toolset>darwin:<cxxflags>-pedantic
+ <toolset>darwin:<cxxflags>-Wno-long-long
+ #<toolset>pathscale:<cxxflags>-Wextra
+ <toolset>pathscale:<cxxflags>-Wno-long-long
+ <toolset>pathscale:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wextra
+ <toolset>clang:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wno-long-long
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
+ <toolset>msvc:<cxxflags>/wd4127
+# Note: Some of the remarks from the Intel compiler are disabled
+# remark #304: access control not specified ("public" by default)
+# remark #383: value copied to temporary, reference to temporary used
+# remark #1418: external function definition with no prior declaration
+ <toolset>intel:<cxxflags>-wd304,383,1418
+ ;
+
+rule chrono-run ( sources )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_header ]
+ ;
+}
+rule chrono-run2 ( sources : name )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(name)_header ]
+ ;
+}
+
+
+rule chrono-run-mt ( sources )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_header ]
+ ;
+}
+rule chrono-run2-mt ( sources : name )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(name)_header ]
+ ;
+}
+rule chrono-compile ( sources )
+{
+ return
+ [ compile $(sources)
+ :
+ : $(sources[1]:B)_lib ]
+ [ compile $(sources)
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment the following line
+ <define>BOOST_SYSTEM_INLINED
+ : $(sources[1]:B)_header ]
+ ;
+}
+
+rule chrono-compile2 ( sources : name )
+{
+ return
+ [ compile $(sources)
+ :
+ : $(name)_lib ]
+ [ compile $(sources)
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment the following line
+ <define>BOOST_SYSTEM_INLINED
+ : $(name)_header ]
+ ;
+}
+
+ test-suite "perf"
+ :
+ [ chrono-run store_now_in_vector.cpp ]
+ ;
+
Added: trunk/libs/chrono/perf/store_now_in_vector.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/perf/store_now_in_vector.cpp 2011-10-02 12:27:15 EDT (Sun, 02 Oct 2011)
@@ -0,0 +1,49 @@
+// Copyright 2011 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp>
+#include <boost/chrono/stopwatches/simple_stopwatch.hpp>
+#include <vector>
+
+static const std::size_t size = 1000000;
+
+template <typename Clock>
+void perf(std::vector<typename Clock::time_point>& vec)
+{
+ typedef boost::chrono::stopwatch_reporter<boost::chrono::simple_stopwatch<boost::chrono::high_resolution_clock> > Reporter;
+ Reporter rp;
+ for (int i=size; i>0; --i)
+ {
+ vec[i]=Clock::now();
+ //vec[i]=typename Clock::time_point(typename Clock::time_point::duration(i));
+ }
+}
+
+template <typename Clock>
+void test()
+{
+ std::vector<typename Clock::time_point> vec(size);
+ perf<Clock>(vec);
+ std::size_t cnt=0;
+ for (int i=size; i>1; --i)
+ {
+ if (vec[i]==vec[i-1]) ++cnt;
+ }
+ std::cout << cnt << std::endl;
+}
+
+int main() {
+
+ test<boost::chrono::system_clock>();
+#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
+ test<boost::chrono::steady_clock>();
+#endif
+#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
+ test<boost::chrono::process_real_cpu_clock>();
+#endif
+ test<boost::chrono::high_resolution_clock>();
+ return 1;
+}
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