Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add example for rope

  • Loading branch information...
commit 8d1dba58ee59f2aad2d3256df4797255564cc66b 1 parent cdf2c96
@gfx authored
Showing with 62 additions and 0 deletions.
  1. +11 −0 Makefile
  2. +51 −0 example/rope.cpp
View
11 Makefile
@@ -0,0 +1,11 @@
+
+rope: scoped_timer.hpp example/rope.cpp
+ @echo "GNU rope"
+ g++ -I. -O3 -o rope example/rope.cpp
+ ./rope
+ @echo "STLPort rope"
+ @rm rope
+ g++ -I. -O3 -DSTLP_ROPE -I/usr/include/stlport -lstlport -o rope example/rope.cpp
+ ./rope
+ @rm rope
+
View
51 example/rope.cpp
@@ -0,0 +1,51 @@
+#include <iostream>
+#include <string>
+#ifdef STLP_ROPE
+#include <rope>
+#else
+#include <ext/rope>
+#endif
+#include "scoped_timer.hpp"
+
+#ifdef STLP_ROPE
+typedef std::rope<char> rope;
+#else
+typedef __gnu_cxx::rope<char> rope;
+#endif
+
+template <typename Rope>
+void doit(const int N) {
+ Rope s;
+ for(int i = 0; i < N; ++i) {
+ s.append("foo bar baz\n");
+ }
+}
+
+
+
+int main() {
+ using namespace gfx;
+
+ const int N = 1000*1000;
+ gfx::scoped_timer_cputime::elapsed_type e = 0.0;
+
+ {
+ gfx::scoped_timer_cputime t(e, "rope");
+ doit<rope>(N);
+ }
+ {
+ gfx::scoped_timer_cputime t(e, "rope");
+ doit<rope>(N);
+ }
+ {
+ gfx::scoped_timer_cputime t(e, "string");
+ doit<std::string>(N);
+ }
+ {
+ gfx::scoped_timer_cputime t(e, "string");
+ doit<std::string>(N);
+ }
+
+ return 0;
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.