Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9de4dec

Browse files
author
Greg Clayton
committedMar 22, 2013
Much more cleanup on the performance testing infrastructure:
- Added new abtract Results class to keep CoreFoundation out of the tests. There are many subclasses for different settings: Results::Result::Dictionary Results::Result::Array Results::Result::Unsigned Results::Result::Double Results::Result::String - Gauge<T> can now write themselves out via a templatized write to results function: template <class T> Results::ResultSP GetResult (const char *description, T value); - There are four specializations of this so far: template <> Results::ResultSP GetResult (const char *description, double value); template <> Results::ResultSP GetResult (const char *description, uint64_t value); template <> Results::ResultSP GetResult (const char *description, std::string value); template <> Results::ResultSP GetResult (const char *description, MemoryStats value); - Don't emit the virtual memory reading from the task info call as it really doesn't mean much as it includes way too much (shared cache + other stuff we don't have control over) - Fixed other test cases to build correctly and use the new classes git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@177696 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b6b7f3e commit 9de4dec

File tree

19 files changed

+1183
-371
lines changed

19 files changed

+1183
-371
lines changed
 
Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
#!/bin/bash
22

3-
mkdir llvm-build
3+
if [ -d "llvm-build" ]; then
4+
echo "Using existing 'llvm-build' directory..."
5+
else
6+
mkdir llvm-build
7+
fi
8+
49
cd llvm-build
5-
svn co --revision 176809 http://llvm.org/svn/llvm-project/llvm/trunk llvm
6-
( cd llvm/tools ; svn co --revision 176809 http://llvm.org/svn/llvm-project/cfe/trunk clang )
7-
mkdir build
8-
cd build
9-
../llvm/configure --enable-targets=x86_64,arm --build=x86_64-apple-darwin10 --enable-optimized --disable-assertions
10-
make -j8
10+
11+
if [ -d "llvm" ]; then
12+
echo "Using existing 'llvm' directory..."
13+
else
14+
svn co --revision 176809 http://llvm.org/svn/llvm-project/llvm/trunk llvm
15+
( cd llvm/tools ; svn co --revision 176809 http://llvm.org/svn/llvm-project/cfe/trunk clang )
16+
fi
17+
18+
if [ ! -d "build" ]; then
19+
mkdir build
20+
cd build
21+
../llvm/configure --enable-targets=x86_64,arm --build=x86_64-apple-darwin10 --disable-optimized --disable-assertions --enable-libcpp
22+
make -j8 DEBUG_SYMBOLS=1
23+
fi
24+
25+
26+

‎tools/lldb-perf/common/clang/lldb_perf_clang.cpp

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#include <CoreFoundation/CoreFoundation.h>
11-
1210
#include "lldb-perf/lib/Timer.h"
1311
#include "lldb-perf/lib/Metric.h"
1412
#include "lldb-perf/lib/Measurement.h"
13+
#include "lldb-perf/lib/Results.h"
1514
#include "lldb-perf/lib/TestCase.h"
1615
#include "lldb-perf/lib/Xcode.h"
17-
1816
#include <iostream>
1917
#include <unistd.h>
2018
#include <fstream>
@@ -24,11 +22,15 @@ using namespace lldb_perf;
2422
class ClangTest : public TestCase
2523
{
2624
public:
27-
ClangTest () : TestCase()
25+
ClangTest () :
26+
TestCase(),
27+
m_set_bp_main_by_name(CreateTimeMeasurement([this] () -> void
28+
{
29+
m_target.BreakpointCreateByName("main");
30+
m_target.BreakpointCreateByName("malloc");
31+
}, "breakpoint1-relative-time", "Elapsed time to set a breakpoint at main by name, run and hit the breakpoint.")),
32+
m_delta_memory("breakpoint1-memory-delta", "Memory increase that occurs due to setting a breakpoint at main by name.")
2833
{
29-
m_set_bp_main_by_name = CreateTimeMeasurement([this] () -> void {
30-
m_target.BreakpointCreateByName("main");
31-
}, "break at \"main\"", "time set a breakpoint at main by name, run and hit the breakpoint");
3234
}
3335

3436
virtual
@@ -39,13 +41,10 @@ class ClangTest : public TestCase
3941
virtual bool
4042
Setup (int argc, const char** argv)
4143
{
44+
SetVerbose(true);
4245
m_app_path.assign(argv[1]);
4346
m_out_path.assign(argv[2]);
44-
m_target = m_debugger.CreateTarget(m_app_path.c_str());
45-
m_set_bp_main_by_name();
46-
const char *clang_argv[] = { "clang --version", NULL };
47-
SBLaunchInfo launch_info(clang_argv);
48-
return Launch (launch_info);
47+
return true;
4948
}
5049

5150
void
@@ -59,71 +58,53 @@ class ClangTest : public TestCase
5958
switch (counter)
6059
{
6160
case 0:
62-
m_target.BreakpointCreateByLocation("fmts_tester.mm", 68);
63-
next_action.Continue();
61+
{
62+
m_total_memory.Start();
63+
m_target = m_debugger.CreateTarget(m_app_path.c_str());
64+
const char *clang_argv[] = { "clang --version", NULL };
65+
m_delta_memory.Start();
66+
m_set_bp_main_by_name();
67+
m_delta_memory.Stop();
68+
SBLaunchInfo launch_info(clang_argv);
69+
Launch (launch_info);
70+
}
6471
break;
6572
case 1:
66-
DoTest ();
67-
next_action.Continue();
73+
next_action.StepOver(m_thread);
6874
break;
6975
case 2:
70-
DoTest ();
71-
next_action.Continue();
76+
next_action.StepOver(m_thread);
7277
break;
7378
case 3:
74-
DoTest ();
75-
next_action.Continue();
76-
break;
77-
case 4:
78-
DoTest ();
79-
next_action.Continue();
80-
break;
81-
case 5:
82-
DoTest ();
83-
next_action.Continue();
84-
break;
85-
case 6:
86-
DoTest ();
87-
next_action.Continue();
88-
break;
89-
case 7:
90-
DoTest ();
91-
next_action.Continue();
92-
break;
93-
case 8:
94-
DoTest ();
95-
next_action.Continue();
96-
break;
97-
case 9:
98-
DoTest ();
99-
next_action.Continue();
100-
break;
101-
case 10:
102-
DoTest ();
103-
next_action.Continue();
79+
next_action.StepOver(m_thread);
10480
break;
10581
default:
82+
m_total_memory.Stop();
10683
next_action.Kill();
10784
break;
10885
}
10986
}
11087

11188
void
112-
Results ()
89+
WriteResults (Results &results)
11390
{
114-
CFCMutableArray array;
115-
m_set_bp_main_by_name.Write(array);
116-
117-
CFDataRef xmlData = CFPropertyListCreateData(kCFAllocatorDefault, array.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL);
91+
Results::Dictionary& results_dict = results.GetDictionary();
11892

119-
CFURLRef file = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)m_out_path.c_str(), m_out_path.size(), FALSE);
93+
m_set_bp_main_by_name.WriteAverageValue(results);
94+
m_delta_memory.WriteAverageValue(results);
95+
96+
results_dict.Add ("breakpoint1-memory-total",
97+
"The total memory that the current process is using after setting the first breakpoint.",
98+
m_total_memory.GetStopValue().GetResult(NULL, NULL));
12099

121-
CFURLWriteDataAndPropertiesToResource(file,xmlData,NULL,NULL);
100+
results.Write(m_out_path.c_str());
122101
}
123102

124103
private:
125104
// C++ formatters
126105
TimeMeasurement<std::function<void()>> m_set_bp_main_by_name;
106+
MemoryMeasurement<std::function<void()>> m_delta_memory;
107+
MemoryGauge m_total_memory;
127108
std::string m_app_path;
128109
std::string m_out_path;
129110

‎tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class StepTest : public TestCase
2222
virtual
2323
~StepTest() {}
2424

25-
virtual void
25+
virtual bool
2626
Setup (int argc, const char **argv)
2727
{
2828
m_app_path.assign(argv[1]);
@@ -33,14 +33,29 @@ class StepTest : public TestCase
3333
const char* file_arg = m_app_path.c_str();
3434
const char* empty = nullptr;
3535
const char* args[] = {file_arg, empty};
36+
SBLaunchInfo launch_info (args);
3637

37-
Launch (args,".");
38+
return Launch (launch_info);
3839
}
3940

40-
private:
4141
void
4242
DoOneStep (int sequence)
4343
{
44+
45+
}
46+
47+
48+
void
49+
WriteResults (Results &results)
50+
{
51+
// results.Write(m_out_path.c_str());
52+
}
53+
54+
55+
private:
56+
virtual void
57+
TestStep (int counter, ActionWanted &next_action)
58+
{
4459

4560
}
4661

@@ -61,7 +76,7 @@ int main(int argc, const char * argv[])
6176
return -1;
6277
}
6378

64-
StepTest skt;
65-
TestCase::Run(skt,argc,argv);
79+
StepTest test;
80+
TestCase::Run(test,argc,argv);
6681
return 0;
6782
}

‎tools/lldb-perf/darwin/formatters/formatters.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,27 +197,21 @@ class FormattersTest : public TestCase
197197
}
198198
}
199199

200-
void
201-
Results ()
200+
virtual void
201+
WriteResults (Results &results)
202202
{
203-
CFCMutableArray array;
204-
m_dump_std_vector_measurement.Write(array);
205-
m_dump_std_list_measurement.Write(array);
206-
m_dump_std_map_measurement.Write(array);
207-
m_dump_std_string_measurement.Write(array);
208-
209-
m_dump_nsstring_measurement.Write(array);
210-
m_dump_nsarray_measurement.Write(array);
211-
m_dump_nsdictionary_measurement.Write(array);
212-
m_dump_nsset_measurement.Write(array);
213-
m_dump_nsbundle_measurement.Write(array);
214-
m_dump_nsdate_measurement.Write(array);
215-
216-
CFDataRef xmlData = CFPropertyListCreateData(kCFAllocatorDefault, array.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL);
217-
218-
CFURLRef file = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)m_out_path.c_str(), m_out_path.size(), FALSE);
219-
220-
CFURLWriteDataAndPropertiesToResource(file,xmlData,NULL,NULL);
203+
m_dump_std_vector_measurement.WriteAverageValue(results);
204+
m_dump_std_list_measurement.WriteAverageValue(results);
205+
m_dump_std_map_measurement.WriteAverageValue(results);
206+
m_dump_std_string_measurement.WriteAverageValue(results);
207+
208+
m_dump_nsstring_measurement.WriteAverageValue(results);
209+
m_dump_nsarray_measurement.WriteAverageValue(results);
210+
m_dump_nsdictionary_measurement.WriteAverageValue(results);
211+
m_dump_nsset_measurement.WriteAverageValue(results);
212+
m_dump_nsbundle_measurement.WriteAverageValue(results);
213+
m_dump_nsdate_measurement.WriteAverageValue(results);
214+
results.Write(m_out_path.c_str());
221215
}
222216

223217
private:

‎tools/lldb-perf/darwin/sketch/sketch.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,15 @@ class SketchTest : public TestCase
179179
}
180180
}
181181

182-
void
183-
Results ()
182+
virtual void
183+
WriteResults (Results &results)
184184
{
185-
CFCMutableArray array;
186-
m_fetch_frames_measurement.Write(array);
187-
m_file_line_bp_measurement.Write(array);
188-
m_fetch_modules_measurement.Write(array);
189-
m_fetch_vars_measurement.Write(array);
190-
m_run_expr_measurement.Write(array);
191-
192-
CFDataRef xmlData = CFPropertyListCreateData(kCFAllocatorDefault, array.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL);
193-
194-
CFURLRef file = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)m_out_path.c_str(), m_out_path.size(), FALSE);
195-
196-
CFURLWriteDataAndPropertiesToResource(file,xmlData,NULL,NULL);
185+
m_fetch_frames_measurement.WriteAverageValue(results);
186+
m_file_line_bp_measurement.WriteAverageValue(results);
187+
m_fetch_modules_measurement.WriteAverageValue(results);
188+
m_fetch_vars_measurement.WriteAverageValue(results);
189+
m_run_expr_measurement.WriteAverageValue(results);
190+
results.Write(m_out_path.c_str());
197191
}
198192

199193
private:

‎tools/lldb-perf/lib/Gauge.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//===-- Gauge.cpp -----------------------------------------------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include "Gauge.h"
11+
12+
template <>
13+
lldb_perf::Results::ResultSP
14+
lldb_perf::GetResult (const char *description, double value)
15+
{
16+
if (description && description[0])
17+
{
18+
std::unique_ptr<Results::Dictionary> value_dict_ap (new Results::Dictionary ());
19+
value_dict_ap->AddString("description", NULL, description);
20+
value_dict_ap->AddDouble("value", NULL, value);
21+
return Results::ResultSP (value_dict_ap.release());
22+
}
23+
return Results::ResultSP (new Results::Double (NULL, NULL, value));
24+
}
25+
26+
template <>
27+
lldb_perf::Results::ResultSP
28+
lldb_perf::GetResult (const char *description, uint64_t value)
29+
{
30+
if (description && description[0])
31+
{
32+
std::unique_ptr<Results::Dictionary> value_dict_ap (new Results::Dictionary ());
33+
value_dict_ap->AddString("description", NULL, description);
34+
value_dict_ap->AddUnsigned("value", NULL, value);
35+
return Results::ResultSP (value_dict_ap.release());
36+
}
37+
return Results::ResultSP (new Results::Unsigned (NULL, NULL, value));
38+
}
39+
40+
template <>
41+
lldb_perf::Results::ResultSP
42+
lldb_perf::GetResult (const char *description, std::string value)
43+
{
44+
if (description && description[0])
45+
{
46+
std::unique_ptr<Results::Dictionary> value_dict_ap (new Results::Dictionary ());
47+
value_dict_ap->AddString("description", NULL, description);
48+
value_dict_ap->AddString("value", NULL, value.c_str());
49+
return Results::ResultSP (value_dict_ap.release());
50+
}
51+
return Results::ResultSP (new Results::String (NULL, NULL, value.c_str()));
52+
}

0 commit comments

Comments
 (0)