summaryrefslogtreecommitdiff
path: root/tools/lldb-perf/lib/Gauge.cpp
blob: bbde3d8f868b48fea0023b809b634b8cd557eaf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//===-- Gauge.cpp -----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "Gauge.h"
#include "lldb/lldb-forward.h"

template <>
lldb_perf::Results::ResultSP lldb_perf::GetResult(const char *description,
                                                  double value) {
  if (description && description[0]) {
    std::unique_ptr<Results::Dictionary> value_dict_ap(
        new Results::Dictionary());
    value_dict_ap->AddString("description", NULL, description);
    value_dict_ap->AddDouble("value", NULL, value);
    return Results::ResultSP(value_dict_ap.release());
  }
  return Results::ResultSP(new Results::Double(NULL, NULL, value));
}

template <>
lldb_perf::Results::ResultSP lldb_perf::GetResult(const char *description,
                                                  uint64_t value) {
  if (description && description[0]) {
    std::unique_ptr<Results::Dictionary> value_dict_ap(
        new Results::Dictionary());
    value_dict_ap->AddString("description", NULL, description);
    value_dict_ap->AddUnsigned("value", NULL, value);
    return Results::ResultSP(value_dict_ap.release());
  }
  return Results::ResultSP(new Results::Unsigned(NULL, NULL, value));
}

template <>
lldb_perf::Results::ResultSP lldb_perf::GetResult(const char *description,
                                                  std::string value) {
  if (description && description[0]) {
    std::unique_ptr<Results::Dictionary> value_dict_ap(
        new Results::Dictionary());
    value_dict_ap->AddString("description", NULL, description);
    value_dict_ap->AddString("value", NULL, value.c_str());
    return Results::ResultSP(value_dict_ap.release());
  }
  return Results::ResultSP(new Results::String(NULL, NULL, value.c_str()));
}