本文整理汇总了C++中SkString::find方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::find方法的具体用法?C++ SkString::find怎么用?C++ SkString::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: benchmark_loop
/**
* Takes argc,argv along with one of the benchmark functions defined above.
* Will loop along all skp files and perform measurments.
*
* Returns a SkScalar representing CPU time taken during benchmark.
* As a side effect, it spits the timer result to stdout.
* Will return -1.0 on error.
*/
static bool benchmark_loop(
int argc,
char **argv,
const BenchmarkControl& benchControl,
SkTArray<Histogram>& histogram) {
static const SkString timeFormat("%f");
TimerData timerData(argc - 1);
for (int index = 1; index < argc; ++index) {
BenchTimer timer;
SkString path(argv[index]);
SkAutoTUnref<SkPicture> pic(pic_from_path(path.c_str()));
if (NULL == pic) {
SkDebugf("Couldn't create picture. Ignoring path: %s\n", path.c_str());
continue;
}
benchControl.fFunction(benchControl.fType, benchControl.fTileSize, path, pic, &timer);
SkAssertResult(timerData.appendTimes(&timer));
histogram[index - 1].fPath = path;
histogram[index - 1].fCpuTime = SkDoubleToScalar(timer.fCpu);
}
const SkString timerResult = timerData.getResult(
/*doubleFormat = */ timeFormat.c_str(),
/*result = */ TimerData::kAvg_Result,
/*configName = */ benchControl.fName.c_str(),
/*timerFlags = */ TimerData::kCpu_Flag);
const char findStr[] = "= ";
int pos = timerResult.find(findStr);
if (-1 == pos) {
SkDebugf("Unexpected output from TimerData::getResult(...). Unable to parse.");
return false;
}
SkScalar cpuTime = SkDoubleToScalar(atof(timerResult.c_str() + pos + sizeof(findStr) - 1));
if (cpuTime == 0) { // atof returns 0.0 on error.
SkDebugf("Unable to read value from timer result.\n");
return false;
}
return true;
}