summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/timer/example
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/timer/example
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/timer/example')
-rw-r--r--src/boost/libs/timer/example/auto_cpu_timer_example.cpp19
-rw-r--r--src/boost/libs/timer/example/timex.cpp47
2 files changed, 66 insertions, 0 deletions
diff --git a/src/boost/libs/timer/example/auto_cpu_timer_example.cpp b/src/boost/libs/timer/example/auto_cpu_timer_example.cpp
new file mode 100644
index 00000000..02213e3b
--- /dev/null
+++ b/src/boost/libs/timer/example/auto_cpu_timer_example.cpp
@@ -0,0 +1,19 @@
+// auto_cpu_timer_example.cpp ------------------------------------------------------//
+
+// Copyright Beman Dawes 2006
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/timer/timer.hpp>
+#include <cmath>
+
+int main()
+{
+ boost::timer::auto_cpu_timer t;
+
+ for ( long i = 0; i < 100000000; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+}
diff --git a/src/boost/libs/timer/example/timex.cpp b/src/boost/libs/timer/example/timex.cpp
new file mode 100644
index 00000000..f0597ef9
--- /dev/null
+++ b/src/boost/libs/timer/example/timex.cpp
@@ -0,0 +1,47 @@
+// timex: timed execution program ------------------------------------------//
+
+// Copyright Beman Dawes 2007
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/timer for documentation.
+
+#include <boost/timer/timer.hpp>
+#include <cstdlib>
+#include <string>
+#include <iostream>
+
+int main( int argc, char * argv[] )
+{
+ if ( argc == 1 )
+ {
+ std::cout << "invoke: timex [-v] command [args...]\n"
+ " command will be executed and timings displayed\n"
+ " -v option causes command and args to be displayed\n";
+ return 1;
+ }
+
+ std::string s;
+
+ bool verbose = false;
+ if ( argc > 1 && *argv[1] == '-' && *(argv[1]+1) == 'v' )
+ {
+ verbose = true;
+ ++argv;
+ --argc;
+ }
+
+ for ( int i = 1; i < argc; ++i )
+ {
+ if ( i > 1 ) s += ' ';
+ s += argv[i];
+ }
+
+ if ( verbose )
+ { std::cout << "command: \"" << s.c_str() << "\"\n"; }
+
+ boost::timer::auto_cpu_timer t(" %ws elapsed wall-clock time\n");
+
+ return std::system( s.c_str() );
+}