MCPcopy Create free account
hub / github.com/apple/foundationdb / getMetrics

Method getMetrics

bindings/java/JavaWorkload.cpp:446–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444 }
445
446 void getMetrics(jobject workload, const std::string& workloadName, std::vector<FDBPerfMetric>& result) {
447 auto clazz = getClass(workloadName.c_str());
448 auto perfMetricClass = getClass("Lcom/apple/foundationdb/testing/PerfMetric;");
449 auto nameId = getField(perfMetricClass, "name", "Ljava/lang/String;");
450 auto valueId = getField(perfMetricClass, "value", "D");
451 auto averagedId = getField(perfMetricClass, "averaged", "Z");
452 auto formatCodeId = getField(perfMetricClass, "formatCode", "Ljava/lang/String;");
453 auto v = env->CallObjectMethod(workload, getMethod(clazz, "getMetrics", "()Ljava/util/List;"));
454 checkException();
455 auto listClass = getClass("java/util/List");
456 auto iter = env->CallObjectMethod(v, getMethod(listClass, "iterator", "()Ljava/util/Iterator;"));
457 checkException();
458 auto iterClass = getClass("java/util/Iterator");
459 auto hasNextM = getMethod(iterClass, "hasNext", "()Z");
460 auto nextM = getMethod(iterClass, "next", "()Ljava/lang/Object;");
461 jboolean hasNext = env->CallBooleanMethod(iter, hasNextM);
462 checkException();
463 while (hasNext) {
464 auto perfMetric = env->CallObjectMethod(iter, nextM);
465 checkException();
466 auto name = jtoStr(jstring(env->GetObjectField(perfMetric, nameId)));
467 checkException();
468 auto value = env->GetDoubleField(perfMetric, valueId);
469 checkException();
470 auto averaged = env->GetBooleanField(perfMetric, averagedId);
471 checkException();
472 auto formatCode = jtoStr(jstring(env->GetObjectField(perfMetric, formatCodeId)));
473 result.emplace_back(FDBPerfMetric{ name, value, bool(averaged), formatCode });
474 hasNext = env->CallBooleanMethod(iter, hasNextM);
475 checkException();
476 }
477 return;
478 }
479
480 jobject createDatabase(jobject workload, FDBDatabase* db) {
481 auto executor = env->CallObjectMethod(workload,

Callers 1

getMetricsMethod · 0.45

Calls 3

getMethodFunction · 0.85
emplace_backMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected