Hash :
559a2e8c
Author :
Date :
2015-03-16T17:25:51
Move the ANGLE tests project to src/ *re-re-land with fix for Chrome's angle tests* BUG=angleproject:945 Change-Id: I3c64e2edc776c299791440f65f22450855eb6dfa Reviewed-on: https://chromium-review.googlesource.com/260448 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "perf_test.h"
#include <stdio.h>
#include <stdarg.h>
#include <vector>
namespace {
namespace base {
std::string FormatString(const char *fmt, va_list vararg) {
static std::vector<char> buffer(512);
// Attempt to just print to the current buffer
int len = vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
if (len < 0 || static_cast<size_t>(len) >= buffer.size()) {
// Buffer was not large enough, calculate the required size and resize the buffer
len = vsnprintf(NULL, 0, fmt, vararg);
buffer.resize(len + 1);
// Print again
vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
}
return std::string(buffer.data(), len);
}
std::string StringPrintf(const char *fmt, ...) {
va_list vararg;
va_start(vararg, fmt);
std::string result = FormatString(fmt, vararg);
va_end(vararg);
return result;
}
std::string UintToString(unsigned int value) {
return StringPrintf("%u", value);
}
std::string DoubleToString(double value) {
return StringPrintf("%.10lf", value);
}
}
std::string ResultsToString(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& values,
const std::string& prefix,
const std::string& suffix,
const std::string& units,
bool important) {
// <*>RESULT <graph_name>: <trace_name>= <value> <units>
// <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
// <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
return base::StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n",
important ? "*" : "", measurement.c_str(), modifier.c_str(),
trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
units.c_str());
}
void PrintResultsImpl(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& values,
const std::string& prefix,
const std::string& suffix,
const std::string& units,
bool important) {
fflush(stdout);
printf("%s", ResultsToString(measurement, modifier, trace, values,
prefix, suffix, units, important).c_str());
fflush(stdout);
}
} // namespace
namespace perf_test {
void PrintResult(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
size_t value,
const std::string& units,
bool important) {
PrintResultsImpl(measurement,
modifier,
trace,
base::UintToString(static_cast<unsigned int>(value)),
std::string(),
std::string(),
units,
important);
}
void PrintResult(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
double value,
const std::string& units,
bool important) {
PrintResultsImpl(measurement,
modifier,
trace,
base::DoubleToString(value),
std::string(),
std::string(),
units,
important);
}
void AppendResult(std::string& output,
const std::string& measurement,
const std::string& modifier,
const std::string& trace,
size_t value,
const std::string& units,
bool important) {
output += ResultsToString(
measurement,
modifier,
trace,
base::UintToString(static_cast<unsigned int>(value)),
std::string(),
std::string(),
units,
important);
}
void PrintResult(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& value,
const std::string& units,
bool important) {
PrintResultsImpl(measurement,
modifier,
trace,
value,
std::string(),
std::string(),
units,
important);
}
void AppendResult(std::string& output,
const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& value,
const std::string& units,
bool important) {
output += ResultsToString(measurement,
modifier,
trace,
value,
std::string(),
std::string(),
units,
important);
}
void PrintResultMeanAndError(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& mean_and_error,
const std::string& units,
bool important) {
PrintResultsImpl(measurement, modifier, trace, mean_and_error,
"{", "}", units, important);
}
void AppendResultMeanAndError(std::string& output,
const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& mean_and_error,
const std::string& units,
bool important) {
output += ResultsToString(measurement, modifier, trace, mean_and_error,
"{", "}", units, important);
}
void PrintResultList(const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& values,
const std::string& units,
bool important) {
PrintResultsImpl(measurement, modifier, trace, values,
"[", "]", units, important);
}
void AppendResultList(std::string& output,
const std::string& measurement,
const std::string& modifier,
const std::string& trace,
const std::string& values,
const std::string& units,
bool important) {
output += ResultsToString(measurement, modifier, trace, values,
"[", "]", units, important);
}
void PrintSystemCommitCharge(const std::string& test_name,
size_t charge,
bool important) {
PrintSystemCommitCharge(stdout, test_name, charge, important);
}
void PrintSystemCommitCharge(FILE* target,
const std::string& test_name,
size_t charge,
bool important) {
fprintf(target, "%s", SystemCommitChargeToString(test_name, charge,
important).c_str());
}
std::string SystemCommitChargeToString(const std::string& test_name,
size_t charge,
bool important) {
std::string trace_name(test_name);
std::string output;
AppendResult(output,
"commit_charge",
std::string(),
"cc" + trace_name,
charge,
"kb",
important);
return output;
}
} // namespace perf_test