From: Sam Moore Date: Sat, 4 Oct 2014 07:18:27 +0000 (+0800) Subject: Turtles all the way down X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ec45b44e3a44e12463c63ec09d63c648602ce866;p=ipdf%2Fcode.git Turtles all the way down Also fix up DebugScript's performance data I can actually plot things! Still haven't actually plotted things, but in theory I can. --- diff --git a/src/debugscript.cpp b/src/debugscript.cpp index 3d13245..7ca6d98 100644 --- a/src/debugscript.cpp +++ b/src/debugscript.cpp @@ -238,13 +238,14 @@ void DebugScript::PrintPerformance(View * view, Screen * scr) now.clock = clock(); now.object_count = view->Doc().ObjectCount(); now.view_bounds = view->GetBounds(); - // object_count delta clock delta x deltax y deltay w deltaw h deltah - printf("%d\t%d\t%lu\t%lu\t%e\t%e\t%e\t%e\t%e\t%e\t%e\t%e\n", - now.object_count, now.object_count - m_perf_last.object_count, - (uint64_t)now.clock, (uint64_t)(now.clock - m_perf_last.clock), - Double(now.view_bounds.x), Double(now.view_bounds.x - m_perf_last.view_bounds.x), - Double(now.view_bounds.y), Double(now.view_bounds.y - m_perf_last.view_bounds.y), - Double(now.view_bounds.w), Double(now.view_bounds.w - m_perf_last.view_bounds.w), - Double(now.view_bounds.h), Double(now.view_bounds.h - m_perf_last.view_bounds.h)); + + // object_count clock delta_clock x Log10(x) y Log10(y) w Log10(w) Size(w) + printf("%d\t%lu\t%lu\t%s\t%f\t%s\t%f\t%s\t%f\t%lu\n", + now.object_count, (uint64_t)now.clock, + (uint64_t)(now.clock - m_perf_last.clock), + Str(now.view_bounds.x).c_str(), Log10(now.view_bounds.x), + Str(now.view_bounds.y).c_str(), Log10(now.view_bounds.y), + Str(now.view_bounds.w).c_str(), Log10(now.view_bounds.w), + Size(now.view_bounds.w)); m_perf_last = now; } diff --git a/src/debugscript.h b/src/debugscript.h index d39807d..fd1a195 100644 --- a/src/debugscript.h +++ b/src/debugscript.h @@ -67,7 +67,7 @@ private: { clock_t clock; unsigned object_count; - Rect view_bounds; + VRect view_bounds; }; PerformanceData m_perf_start; diff --git a/src/eye_of_the_rabbit.script b/src/eye_of_the_rabbit.script index b4b22c6..12e6af9 100644 --- a/src/eye_of_the_rabbit.script +++ b/src/eye_of_the_rabbit.script @@ -5,6 +5,7 @@ debugfont off clearperf label start printperf +clear debug Add rabbit 1 loadsvg svg-tests/rabbit_simple.svg loop 250 pxzoom 508 305 1 @@ -16,6 +17,5 @@ loadsvg svg-tests/rabbit_simple.svg loop 500 pxzoom 508 305 -1 loop 500 pxzoom 508 305 1 debug Repeat -clear goto start wait diff --git a/src/gmprat.h b/src/gmprat.h index 3e275d2..f5a2f1f 100644 --- a/src/gmprat.h +++ b/src/gmprat.h @@ -103,6 +103,10 @@ class Gmprat Gmprat Abs() const {Gmprat a(*this); mpq_abs(a.m_op, a.m_op); return a;} + size_t Size() const + { + return sizeof(uint64_t) * (mpq_numref(m_op)->_mp_alloc + mpq_denref(m_op)->_mp_alloc); + } private: friend std::ostream& operator<<(std::ostream& os, const Gmprat & fith); @@ -115,6 +119,9 @@ inline std::ostream & operator<<(std::ostream & os, const Gmprat & fith) return os; } +inline std::string Str(const Gmprat & g) {return g.Str();} +inline double Log10(const Gmprat & g) {return g.Log10();} +inline size_t Size(const Gmprat & g) {return g.Size();} diff --git a/src/main.cpp b/src/main.cpp index e556fe4..a4c570b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,7 +46,7 @@ int main(int argc, char ** argv) const char * output_bmp = NULL; const char * input_filename = NULL; const char * input_text = NULL; - float b[4] = {0,0,1,1}; + Real b[4] = {0,0,1,1}; int max_frames = -1; bool hide_control_panel = false; bool lazy_rendering = true; @@ -80,10 +80,7 @@ int main(int argc, char ** argv) { if (i+j >= argc) Fatal("No %d bounds component following -b switch", j); - char * e; - b[j-1] = strtof(argv[i+j], &e); - if (*e != '\0') - Fatal("Bounds component %d not a valid float", j); + b[j-1] = RealFromStr(argv[i+j]); } i += 4; break; diff --git a/src/path.h b/src/path.h index 2aa7840..85213c5 100644 --- a/src/path.h +++ b/src/path.h @@ -16,6 +16,7 @@ namespace IPDF { #ifdef TRANSFORM_BEZIERS_TO_PATH + #pragma message "Path using Gmprat for bounds" typedef Gmprat PReal; #else typedef Real PReal; diff --git a/src/real.h b/src/real.h index 35b2c5e..e4d594e 100644 --- a/src/real.h +++ b/src/real.h @@ -61,11 +61,11 @@ namespace IPDF #if REALTYPE == REAL_SINGLE typedef float Real; inline Real RealFromStr(const char * str) {return strtof(str, NULL);} - inline std::string Str(const Real & a) {std::stringstream s; s << a; return s.str();} + //inline std::string Str(const Real & a) {std::stringstream s; s << a; return s.str();} #elif REALTYPE == REAL_DOUBLE typedef double Real; inline Real RealFromStr(const char * str) {return strtod(str, NULL);} - inline std::string Str(const Real & a) {std::stringstream s; s << a; return s.str();} + //inline std::string Str(const Real & a) {std::stringstream s; s << a; return s.str();} #elif REALTYPE == REAL_LONG_DOUBLE typedef long double Real; inline Real RealFromStr(const char * str) {return strtold(str, NULL);} @@ -136,7 +136,10 @@ namespace IPDF inline double Double(long double f) {return (double)(f);} inline double Sqrt(double f) {return sqrt(f);} inline double Abs(double a) {return fabs(a);} - + inline double Log10(double a) {return log(a)/log(10.0);} + inline size_t Size(double a) {return sizeof(a);} + inline size_t Size(float a) {return sizeof(a);} + inline int64_t Int64(double a) { diff --git a/src/svg-tests/turtle.svg b/src/svg-tests/turtle.svg new file mode 100644 index 0000000..b09a4cb --- /dev/null +++ b/src/svg-tests/turtle.svg @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/src/turtles_all_the_way_down.script b/src/turtles_all_the_way_down.script new file mode 100644 index 0000000..af85e89 --- /dev/null +++ b/src/turtles_all_the_way_down.script @@ -0,0 +1,34 @@ +# BECAUSE I CAN +gpu +lazy +debugfont off +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 +loadsvg svg-tests/turtle.svg +loop 50 pxzoom 430 170 1 + +# Hmm, we sort of need a for loop... + +clearperf +label start +printperf +loop 500 pxzoom 430 170 -1 +loop 500 pxzoom 430 170 1 +goto start +wait diff --git a/src/view.h b/src/view.h index 1cb2221..cd94420 100644 --- a/src/view.h +++ b/src/view.h @@ -19,6 +19,7 @@ namespace IPDF { #ifdef TRANSFORM_BEZIERS_TO_PATH + #pragma message "View using Gmprat for bounds" typedef Gmprat VReal; #else typedef Real VReal;