currentAction.type = AT_Debug;
getline(inp,currentAction.textargs);
}
+ else if (actionType == "clear")
+ {
+ currentAction.type = AT_ClearDocument;
+ }
+ else if (actionType == "clearperf")
+ {
+ currentAction.type = AT_ClearPerformance;
+ }
+ else if (actionType == "printperf")
+ {
+ currentAction.type = AT_PrintPerformance;
+ }
+ else if (actionType == "recordperf")
+ {
+ currentAction.type = AT_RecordPerformance;
+ }
+ else if (actionType == "debugfont")
+ {
+ currentAction.type = AT_DebugFont;
+ inp >> currentAction.textargs;
+ }
+
}
bool DebugScript::Execute(View *view, Screen *scr)
if (currentAction.textargs.size() > 0)
Debug("%s", currentAction.textargs.c_str());
break;
+ case AT_ClearDocument:
+ view->Doc().ClearObjects();
+ currentAction.loops = 1;
+ break;
+ case AT_ClearPerformance:
+ ClearPerformance(view, scr);
+ currentAction.loops = 1;
+ break;
+ case AT_PrintPerformance:
+ PrintPerformance(view, scr);
+ currentAction.loops = 1;
+ break;
+ case AT_RecordPerformance:
+ PrintPerformance(view, scr);
+ break;
+ case AT_DebugFont:
+ scr->ShowDebugFont(currentAction.textargs == "1" || currentAction.textargs == "on");
+ currentAction.loops = 1;
+ break;
default:
Fatal("Unknown script command in queue.");
}
currentAction.loops--;
return false;
}
+
+void DebugScript::ClearPerformance(View * view, Screen * scr)
+{
+ m_perf_start.clock = clock();
+ m_perf_start.object_count = view->Doc().ObjectCount();
+ m_perf_start.view_bounds = view->GetBounds();
+ m_perf_last = m_perf_start;
+}
+
+void DebugScript::PrintPerformance(View * view, Screen * scr)
+{
+ DebugScript::PerformanceData now;
+ now.clock = clock();
+ now.object_count = view->Doc().ObjectCount();
+ now.view_bounds = view->GetBounds();
+
+ // 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(Abs(now.view_bounds.x)),
+ Str(now.view_bounds.y).c_str(), Log10(Abs(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;
+}