本文整理汇总了C++中SkBenchLogger类的典型用法代码示例。如果您正苦于以下问题:C++ SkBenchLogger类的具体用法?C++ SkBenchLogger怎么用?C++ SkBenchLogger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkBenchLogger类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tool_main
int tool_main(int argc, char** argv) {
SkCommandLineFlags::Parse(argc, argv);
#if SK_ENABLE_INST_COUNT
if (FLAGS_leaks) {
gPrintInstCount = true;
}
#endif
SkAutoGraphics ag;
// First, parse some flags.
SkBenchLogger logger;
if (FLAGS_logFile.count()) {
logger.SetLogFile(FLAGS_logFile[0]);
}
LoggerResultsWriter logWriter(logger, FLAGS_timeFormat[0]);
MultiResultsWriter writer;
writer.add(&logWriter);
#ifdef SK_BUILD_JSON_WRITER
SkAutoTDelete<JSONResultsWriter> jsonWriter;
if (FLAGS_outResultsFile.count()) {
jsonWriter.reset(SkNEW(JSONResultsWriter(FLAGS_outResultsFile[0])));
writer.add(jsonWriter.get());
}
#endif
// Instantiate after all the writers have been added to writer so that we
// call close() before their destructors are called on the way out.
CallEnd<MultiResultsWriter> ender(writer);
const uint8_t alpha = FLAGS_forceBlend ? 0x80 : 0xFF;
SkTriState::State dither = SkTriState::kDefault;
for (size_t i = 0; i < 3; i++) {
if (strcmp(SkTriState::Name[i], FLAGS_forceDither[0]) == 0) {
dither = static_cast<SkTriState::State>(i);
}
}
BenchMode benchMode = kNormal_BenchMode;
for (size_t i = 0; i < SK_ARRAY_COUNT(BenchMode_Name); i++) {
if (strcmp(FLAGS_mode[0], BenchMode_Name[i]) == 0) {
benchMode = static_cast<BenchMode>(i);
}
}
SkTDArray<int> configs;
bool runDefaultConfigs = false;
// Try user-given configs first.
for (int i = 0; i < FLAGS_config.count(); i++) {
for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(gConfigs)); ++j) {
if (0 == strcmp(FLAGS_config[i], gConfigs[j].name)) {
*configs.append() = j;
} else if (0 == strcmp(FLAGS_config[i], kDefaultsConfigStr)) {
runDefaultConfigs = true;
}
}
}
// If there weren't any, fill in with defaults.
if (runDefaultConfigs) {
for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(gConfigs)); ++i) {
if (gConfigs[i].runByDefault) {
*configs.append() = i;
}
}
}
// Filter out things we can't run.
if (kNormal_BenchMode != benchMode) {
// Non-rendering configs only run in normal mode
for (int i = 0; i < configs.count(); ++i) {
const Config& config = gConfigs[configs[i]];
if (SkBenchmark::kNonRendering_Backend == config.backend) {
configs.remove(i, 1);
--i;
}
}
}
// Set the resource path.
if (!FLAGS_resourcePath.isEmpty()) {
SkBenchmark::SetResourcePath(FLAGS_resourcePath[0]);
}
#if SK_SUPPORT_GPU
for (int i = 0; i < configs.count(); ++i) {
const Config& config = gConfigs[configs[i]];
if (SkBenchmark::kGPU_Backend == config.backend) {
GrContext* context = gContextFactory.get(config.contextType);
if (NULL == context) {
SkDebugf("GrContext could not be created for config %s. Config will be skipped.\n",
config.name);
configs.remove(i);
--i;
continue;
}
if (config.sampleCount > context->getMaxSampleCount()){
SkDebugf(
"Sample count (%d) for config %s is not supported. Config will be skipped.\n",
config.sampleCount, config.name);
configs.remove(i);
//.........这里部分代码省略.........
示例2: run_single_benchmark
static bool run_single_benchmark(const SkString& inputPath,
sk_tools::PictureBenchmark& benchmark) {
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkString err;
err.printf("Could not open file %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
bool success = false;
SkPicture picture(&inputStream, &success, &SkImageDecoder::DecodeStream);
if (!success) {
SkString err;
err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
SkString filename;
sk_tools::get_basename(&filename, inputPath);
SkString result;
result.printf("running bench [%i %i] %s ", picture.width(),
picture.height(), filename.c_str());
gLogger.logProgress(result);
benchmark.run(&picture);
return true;
}
示例3: tool_main
int tool_main(int argc, char** argv) {
SkString usage;
usage.printf("Time drawing .skp files.\n"
"\tPossible arguments for --filter: [%s]\n\t\t[%s]",
filterTypesUsage().c_str(), filterFlagsUsage().c_str());
SkCommandLineFlags::SetUsage(usage.c_str());
SkCommandLineFlags::Parse(argc, argv);
if (FLAGS_repeat < 1) {
SkString error;
error.printf("--repeats must be >= 1. Was %i\n", FLAGS_repeat);
gLogger.logError(error);
exit(-1);
}
if (FLAGS_logFile.count() == 1) {
if (!gLogger.SetLogFile(FLAGS_logFile[0])) {
SkString str;
str.printf("Could not open %s for writing.\n", FLAGS_logFile[0]);
gLogger.logError(str);
// TODO(borenet): We're disabling this for now, due to
// write-protected Android devices. The very short-term
// solution is to ignore the fact that we have no log file.
//exit(-1);
}
}
#if SK_ENABLE_INST_COUNT
gPrintInstCount = true;
#endif
SkAutoGraphics ag;
sk_tools::PictureBenchmark benchmark;
setup_benchmark(&benchmark);
int failures = 0;
for (int i = 0; i < FLAGS_readPath.count(); ++i) {
failures += process_input(FLAGS_readPath[i], benchmark);
}
if (failures != 0) {
SkString err;
err.printf("Failed to run %i benchmarks.\n", failures);
gLogger.logError(err);
return 1;
}
#if LAZY_CACHE_STATS
if (FLAGS_trackDeferredCaching) {
SkDebugf("Total cache hit rate: %f\n",
(double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses));
}
#endif
return 0;
}
示例4: process_input
static int process_input(const char* input,
sk_tools::PictureBenchmark& benchmark) {
SkString inputAsSkString(input);
SkOSFile::Iter iter(input, "skp");
SkString inputFilename;
int failures = 0;
if (iter.next(&inputFilename)) {
do {
SkString inputPath;
sk_tools::make_filepath(&inputPath, inputAsSkString, inputFilename);
if (!run_single_benchmark(inputPath, benchmark)) {
++failures;
}
} while(iter.next(&inputFilename));
} else if (SkStrEndsWith(input, ".skp")) {
if (!run_single_benchmark(inputAsSkString, benchmark)) {
++failures;
}
} else {
SkString warning;
warning.printf("Warning: skipping %s\n", input);
gLogger.logError(warning);
}
return failures;
}
示例5: run_single_benchmark
static void run_single_benchmark(const SkString& inputPath,
sk_tools::PictureBenchmark& benchmark) {
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkString err;
err.printf("Could not open file %s\n", inputPath.c_str());
gLogger.logError(err);
return;
}
SkPicture picture(&inputStream);
SkString filename;
sk_tools::get_basename(&filename, inputPath);
SkString result;
result.printf("running bench [%i %i] %s ", picture.width(), picture.height(),
filename.c_str());
gLogger.logProgress(result);
benchmark.run(&picture);
}
示例6: tool_main
int tool_main(int argc, char** argv) {
#ifdef SK_ENABLE_INST_COUNT
gPrintInstCount = true;
#endif
SkAutoGraphics ag;
SkTArray<SkString> inputs;
sk_tools::PictureBenchmark benchmark;
parse_commandline(argc, argv, &inputs, &benchmark);
int failures = 0;
for (int i = 0; i < inputs.count(); ++i) {
failures += process_input(inputs[i], benchmark);
}
if (failures != 0) {
SkString err;
err.printf("Failed to run %i benchmarks.\n", failures);
gLogger.logError(err);
return 1;
}
return 0;
}
示例7: setup_benchmark
static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
sk_bzero(drawFilters, sizeof(drawFilters));
if (FLAGS_filter.count() > 0) {
const char* filters = FLAGS_filter[0];
const char* colon = strchr(filters, ':');
if (colon) {
int32_t type = -1;
size_t typeLen = colon - filters;
for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
if (typeLen == strlen(gFilterTypes[tIndex])
&& !strncmp(filters, gFilterTypes[tIndex], typeLen)) {
type = SkToS32(tIndex);
break;
}
}
if (type < 0) {
SkString err;
err.printf("Unknown type for --filter %s\n", filters);
gLogger.logError(err);
exit(-1);
}
int flag = -1;
size_t flagLen = strlen(filters) - typeLen - 1;
for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
if (flagLen == strlen(gFilterFlags[fIndex])
&& !strncmp(colon + 1, gFilterFlags[fIndex], flagLen)) {
flag = 1 << fIndex;
break;
}
}
if (flag < 0) {
SkString err;
err.printf("Unknown flag for --filter %s\n", filters);
gLogger.logError(err);
exit(-1);
}
for (int index = 0; index < SkDrawFilter::kTypeCount; ++index) {
if (type != SkDrawFilter::kTypeCount && index != type) {
continue;
}
drawFilters[index] = (sk_tools::PictureRenderer::DrawFilterFlags)
(drawFilters[index] | flag);
}
} else {
SkString err;
err.printf("Unknown arg for --filter %s : missing colon\n", filters);
gLogger.logError(err);
exit(-1);
}
}
if (FLAGS_timers.count() > 0) {
size_t index = 0;
bool timerWall = false;
bool truncatedTimerWall = false;
bool timerCpu = false;
bool truncatedTimerCpu = false;
bool timerGpu = false;
while (index < strlen(FLAGS_timers[0])) {
switch (FLAGS_timers[0][index]) {
case 'w':
timerWall = true;
break;
case 'c':
timerCpu = true;
break;
case 'W':
truncatedTimerWall = true;
break;
case 'C':
truncatedTimerCpu = true;
break;
case 'g':
timerGpu = true;
break;
default:
SkDebugf("mystery character\n");
break;
}
index++;
}
benchmark->setTimersToShow(timerWall, truncatedTimerWall, timerCpu, truncatedTimerCpu,
timerGpu);
}
SkString errorString;
SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
kBench_PictureTool));
if (errorString.size() > 0) {
gLogger.logError(errorString);
}
if (NULL == renderer.get()) {
exit(-1);
}
if (FLAGS_timeIndividualTiles) {
//.........这里部分代码省略.........
示例8: run_single_benchmark
static bool run_single_benchmark(const SkString& inputPath,
sk_tools::PictureBenchmark& benchmark) {
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkString err;
err.printf("Could not open file %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
// Since the old picture has been deleted, all pixels should be cleared.
SkASSERT(gLruImageCache.getImageCacheUsed() == 0);
if (FLAGS_countRAM) {
// Set the limit to zero, so all pixels will be kept
gLruImageCache.setImageCacheLimit(0);
}
bool success = false;
SkPicture* picture;
if (FLAGS_deferImageDecoding) {
picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &lazy_decode_bitmap));
} else {
picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &SkImageDecoder::DecodeMemory));
}
SkAutoTDelete<SkPicture> ad(picture);
if (!success) {
SkString err;
err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
SkString filename;
sk_tools::get_basename(&filename, inputPath);
SkString result;
result.printf("running bench [%i %i] %s ", picture->width(), picture->height(),
filename.c_str());
gLogger.logProgress(result);
benchmark.run(picture);
#if LAZY_CACHE_STATS
if (FLAGS_trackDeferredCaching) {
int32_t cacheHits = SkLazyPixelRef::GetCacheHits();
int32_t cacheMisses = SkLazyPixelRef::GetCacheMisses();
SkLazyPixelRef::ResetCacheStats();
SkString hitString;
hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
gLogger.logProgress(hitString);
gTotalCacheHits += cacheHits;
gTotalCacheMisses += cacheMisses;
}
#endif
if (FLAGS_countRAM) {
SkString ramCount("RAM used for bitmaps: ");
size_t bytes = gLruImageCache.getImageCacheUsed();
if (bytes > 1024) {
size_t kb = bytes / 1024;
if (kb > 1024) {
size_t mb = kb / 1024;
ramCount.appendf("%zi MB\n", mb);
} else {
ramCount.appendf("%zi KB\n", kb);
}
} else {
ramCount.appendf("%zi bytes\n", bytes);
}
gLogger.logProgress(ramCount);
}
return true;
}
示例9: parse_commandline
static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* inputs,
sk_tools::PictureBenchmark*& benchmark) {
const char* argv0 = argv[0];
char* const* stop = argv + argc;
int repeats = DEFAULT_REPEATS;
sk_tools::PictureRenderer::SkDeviceTypes deviceType =
sk_tools::PictureRenderer::kBitmap_DeviceType;
// Create a string to show our current settings.
// TODO: Make it prettier. Currently it just repeats the command line.
SkString commandLine("bench_pictures:");
for (int i = 1; i < argc; i++) {
commandLine.appendf(" %s", *(argv+i));
}
commandLine.append("\n");
bool usePipe = false;
bool multiThreaded = false;
bool useTiles = false;
const char* widthString = NULL;
const char* heightString = NULL;
bool isPowerOf2Mode = false;
const char* mode = NULL;
for (++argv; argv < stop; ++argv) {
if (0 == strcmp(*argv, "--repeat")) {
++argv;
if (argv < stop) {
repeats = atoi(*argv);
if (repeats < 1) {
SkDELETE(benchmark);
gLogger.logError("--repeat must be given a value > 0\n");
exit(-1);
}
} else {
SkDELETE(benchmark);
gLogger.logError("Missing arg for --repeat\n");
usage(argv0);
exit(-1);
}
} else if (0 == strcmp(*argv, "--pipe")) {
usePipe = true;
} else if (0 == strcmp(*argv, "--logFile")) {
argv++;
if (argv < stop) {
if (!gLogger.SetLogFile(*argv)) {
SkString str;
str.printf("Could not open %s for writing.", *argv);
gLogger.logError(str);
usage(argv0);
exit(-1);
}
} else {
gLogger.logError("Missing arg for --logFile\n");
usage(argv0);
exit(-1);
}
} else if (0 == strcmp(*argv, "--mode")) {
SkDELETE(benchmark);
++argv;
if (argv >= stop) {
gLogger.logError("Missing mode for --mode\n");
usage(argv0);
exit(-1);
}
if (0 == strcmp(*argv, "record")) {
benchmark = SkNEW(sk_tools::RecordPictureBenchmark);
} else if (0 == strcmp(*argv, "simple")) {
benchmark = SkNEW(sk_tools::SimplePictureBenchmark);
} else if ((0 == strcmp(*argv, "tile")) || (0 == strcmp(*argv, "pow2tile"))) {
useTiles = true;
mode = *argv;
if (0 == strcmp(*argv, "pow2tile")) {
isPowerOf2Mode = true;
}
++argv;
if (argv >= stop) {
SkString err;
err.printf("Missing width for --mode %s\n", mode);
gLogger.logError(err);
usage(argv0);
exit(-1);
}
widthString = *argv;
++argv;
if (argv >= stop) {
gLogger.logError("Missing height for --mode tile\n");
usage(argv0);
exit(-1);
}
heightString = *argv;
++argv;
if (argv < stop && 0 == strcmp(*argv, "multi")) {
multiThreaded = true;
//.........这里部分代码省略.........
示例10: run_single_benchmark
static bool run_single_benchmark(const SkString& inputPath,
sk_tools::PictureBenchmark& benchmark) {
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkString err;
err.printf("Could not open file %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
SkDiscardableMemoryPool* pool = SkGetGlobalDiscardableMemoryPool();
// Since the old picture has been deleted, all pixels should be cleared.
SkASSERT(pool->getRAMUsed() == 0);
if (FLAGS_countRAM) {
pool->setRAMBudget(SK_MaxU32);
// Set the limit to max, so all pixels will be kept
}
SkPicture::InstallPixelRefProc proc;
if (FLAGS_deferImageDecoding) {
proc = &sk_tools::LazyDecodeBitmap;
} else {
proc = &SkImageDecoder::DecodeMemory;
}
SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
if (NULL == picture.get()) {
SkString err;
err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
SkString filename;
sk_tools::get_basename(&filename, inputPath);
SkString result;
result.printf("running bench [%i %i] %s ", picture->width(), picture->height(),
filename.c_str());
gLogger.logProgress(result);
benchmark.run(picture);
#if LAZY_CACHE_STATS
if (FLAGS_trackDeferredCaching) {
int32_t cacheHits = pool->fCacheHits;
int32_t cacheMisses = pool->fCacheMisses;
pool->fCacheHits = pool->fCacheMisses = 0;
SkString hitString;
hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
gLogger.logProgress(hitString);
gTotalCacheHits += cacheHits;
gTotalCacheMisses += cacheMisses;
}
#endif
if (FLAGS_countRAM) {
SkString ramCount("RAM used for bitmaps: ");
size_t bytes = pool->getRAMUsed();
if (bytes > 1024) {
size_t kb = bytes / 1024;
if (kb > 1024) {
size_t mb = kb / 1024;
ramCount.appendf("%zi MB\n", mb);
} else {
ramCount.appendf("%zi KB\n", kb);
}
} else {
ramCount.appendf("%zi bytes\n", bytes);
}
gLogger.logProgress(ramCount);
}
return true;
}
示例11: parse_commandline
static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* inputs,
sk_tools::PictureBenchmark* benchmark) {
const char* argv0 = argv[0];
char* const* stop = argv + argc;
int repeats = DEFAULT_REPEATS;
sk_tools::PictureRenderer::SkDeviceTypes deviceType =
sk_tools::PictureRenderer::kBitmap_DeviceType;
SkAutoTUnref<sk_tools::PictureRenderer> renderer(NULL);
// Create a string to show our current settings.
// TODO: Make it prettier. Currently it just repeats the command line.
SkString commandLine("bench_pictures:");
for (int i = 1; i < argc; i++) {
commandLine.appendf(" %s", *(argv+i));
}
commandLine.append("\n");
bool usePipe = false;
int numThreads = 1;
bool useTiles = false;
const char* widthString = NULL;
const char* heightString = NULL;
int gridWidth = 0;
int gridHeight = 0;
bool isPowerOf2Mode = false;
bool isCopyMode = false;
const char* xTilesString = NULL;
const char* yTilesString = NULL;
const char* mode = NULL;
bool gridSupported = false;
sk_tools::PictureRenderer::BBoxHierarchyType bbhType =
sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
sk_bzero(drawFilters, sizeof(drawFilters));
SkISize viewport;
viewport.setEmpty();
for (++argv; argv < stop; ++argv) {
if (0 == strcmp(*argv, "--repeat")) {
++argv;
if (argv < stop) {
repeats = atoi(*argv);
if (repeats < 1) {
gLogger.logError("--repeat must be given a value > 0\n");
PRINT_USAGE_AND_EXIT;
}
} else {
gLogger.logError("Missing arg for --repeat\n");
PRINT_USAGE_AND_EXIT;
}
} else if (0 == strcmp(*argv, "--pipe")) {
usePipe = true;
} else if (0 == strcmp(*argv, "--logFile")) {
argv++;
if (argv < stop) {
if (!gLogger.SetLogFile(*argv)) {
SkString str;
str.printf("Could not open %s for writing.", *argv);
gLogger.logError(str);
usage(argv0);
// TODO(borenet): We're disabling this for now, due to
// write-protected Android devices. The very short-term
// solution is to ignore the fact that we have no log file.
//exit(-1);
}
} else {
gLogger.logError("Missing arg for --logFile\n");
PRINT_USAGE_AND_EXIT;
}
} else if (0 == strcmp(*argv, "--multi")) {
++argv;
if (argv >= stop) {
gLogger.logError("Missing arg for --multi\n");
PRINT_USAGE_AND_EXIT;
}
numThreads = atoi(*argv);
if (numThreads < 2) {
gLogger.logError("Number of threads must be at least 2.\n");
PRINT_USAGE_AND_EXIT;
}
} else if (0 == strcmp(*argv, "--bbh")) {
++argv;
if (argv >= stop) {
gLogger.logError("Missing value for --bbh\n");
PRINT_USAGE_AND_EXIT;
}
if (0 == strcmp(*argv, "none")) {
bbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
} else if (0 == strcmp(*argv, "rtree")) {
bbhType = sk_tools::PictureRenderer::kRTree_BBoxHierarchyType;
} else if (0 == strcmp(*argv, "grid")) {
bbhType = sk_tools::PictureRenderer::kTileGrid_BBoxHierarchyType;
++argv;
if (argv >= stop) {
gLogger.logError("Missing width for --bbh grid\n");
PRINT_USAGE_AND_EXIT;
}
gridWidth = atoi(*argv);
++argv;
//.........这里部分代码省略.........