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 #include "lldb/lldb-forward.h" 12 13 template <> 14 lldb_perf::Results::ResultSP 15 lldb_perf::GetResult (const char *description, double value) 16 { 17 if (description && description[0]) 18 { 19 std::unique_ptr<Results::Dictionary> value_dict_ap (new Results::Dictionary ()); 20 value_dict_ap->AddString("description", NULL, description); 21 value_dict_ap->AddDouble("value", NULL, value); 22 return Results::ResultSP (value_dict_ap.release()); 23 } 24 return Results::ResultSP (new Results::Double (NULL, NULL, value)); 25 } 26 27 template <> 28 lldb_perf::Results::ResultSP 29 lldb_perf::GetResult (const char *description, uint64_t value) 30 { 31 if (description && description[0]) 32 { 33 std::unique_ptr<Results::Dictionary> value_dict_ap (new Results::Dictionary ()); 34 value_dict_ap->AddString("description", NULL, description); 35 value_dict_ap->AddUnsigned("value", NULL, value); 36 return Results::ResultSP (value_dict_ap.release()); 37 } 38 return Results::ResultSP (new Results::Unsigned (NULL, NULL, value)); 39 } 40 41 template <> 42 lldb_perf::Results::ResultSP 43 lldb_perf::GetResult (const char *description, std::string value) 44 { 45 if (description && description[0]) 46 { 47 std::unique_ptr<Results::Dictionary> value_dict_ap (new Results::Dictionary ()); 48 value_dict_ap->AddString("description", NULL, description); 49 value_dict_ap->AddString("value", NULL, value.c_str()); 50 return Results::ResultSP (value_dict_ap.release()); 51 } 52 return Results::ResultSP (new Results::String (NULL, NULL, value.c_str())); 53 } 54