Initial checkin of a new project: LLDB Performance Testing Infrastructure
This is a very basic implementation of a library that easily allows to drive LLDB.framework to write test cases for performance
This is separate from the LLDB testsuite in test/ in that:
a) this uses C++ instead of Python to avoid measures being affected by SWIG
b) this is in very early development and needs lots of tweaking before it can be considered functionally complete
c) this is not meant to test correctness but to help catch performance regressions
There is a sample application built against the library (in darwin/sketch) that uses the famous sample app Sketch as an inferior to measure certain basic parameters of LLDB's behavior.
The resulting output is a PLIST much like the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>fetch-frames</key>
<real>0.13161715522222225</real>
</dict>
<dict>
<key>file-line-bkpt</key>
<real>0.029111678750000002</real>
</dict>
<dict>
<key>fetch-modules</key>
<real>0.00026376766666666668</real>
</dict>
<dict>
<key>fetch-vars</key>
<real>0.17820429311111111</real>
</dict>
<dict>
<key>run-expr</key>
<real>0.029676525769230768</real>
</dict>
</array>
</plist>
Areas for improvement:
- code cleanups (I will be out of the office for a couple days this coming week, but please keep ideas coming!)
- more metrics and test cases
- better error checking
This toolkit also comprises a simple event-loop-driven controller for LLDB, similar yet much simpler to what the Driver does to implement the lldb command-line tool.
llvm-svn: 176715
diff --git a/lldb/tools/lldb-perf/lib/Metric.cpp b/lldb/tools/lldb-perf/lib/Metric.cpp
new file mode 100644
index 0000000..885413f
--- /dev/null
+++ b/lldb/tools/lldb-perf/lib/Metric.cpp
@@ -0,0 +1,84 @@
+//
+// Metric.cpp
+// PerfTestDriver
+//
+// Created by Enrico Granata on 3/7/13.
+// Copyright (c) 2013 Apple Inc. All rights reserved.
+//
+
+#include "Metric.h"
+
+#include "CFCMutableArray.h"
+#include "CFCMutableDictionary.h"
+#include "CFCString.h"
+
+using namespace lldb::perf;
+
+template <class T>
+Metric<T>::Metric () : Metric ("")
+{}
+
+template <class T>
+Metric<T>::Metric (const char* n) :
+m_name(n ? n : ""),
+m_dataset ()
+{}
+
+template <class T>
+void
+Metric<T>::append (T v)
+{
+ m_dataset.push_back(v);
+}
+
+template <class T>
+size_t
+Metric<T>::count ()
+{
+ return m_dataset.size();
+}
+
+template <class T>
+T
+Metric<T>::sum ()
+{
+ T sum = 0;
+ for (auto v : m_dataset)
+ sum += v;
+ return sum;
+}
+
+template <class T>
+T
+Metric<T>::average ()
+{
+ return sum()/count();
+}
+
+template <class T>
+const char*
+Metric<T>::name ()
+{
+ return m_name.c_str();
+}
+
+template <class T>
+void Metric<T>::WriteImpl (CFCMutableArray& parent, identity<double>)
+{
+ CFCMutableDictionary dict;
+ dict.AddValueCString(CFCString("name").get(),m_name.c_str(), true);
+ dict.AddValueDouble(CFCString("value").get(),this->average(), true);
+ parent.AppendValue(dict.get(), true);
+}
+
+template <class T>
+void Metric<T>::WriteImpl (CFCMutableArray& parent, identity<mach_vm_size_t>)
+{
+ CFCMutableDictionary dict;
+ dict.AddValueCString(CFCString("name").get(),m_name.c_str(), true);
+ dict.AddValueUInt64(CFCString("value").get(),this->average(), true);
+ parent.AppendValue(dict.get(), true);
+}
+
+template class lldb::perf::Metric<double>;
+template class lldb::perf::Metric<mach_vm_size_t>;