MCPcopy Create free account
hub / github.com/ElementsProject/elements / PrintEnvironment

Method PrintEnvironment

src/leveldb/benchmarks/db_bench.cc:361–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359 }
360
361 void PrintEnvironment() {
362 fprintf(stderr, "LevelDB: version %d.%d\n", kMajorVersion,
363 kMinorVersion);
364
365#if defined(__linux)
366 time_t now = time(nullptr);
367 fprintf(stderr, "Date: %s", ctime(&now)); // ctime() adds newline
368
369 FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
370 if (cpuinfo != nullptr) {
371 char line[1000];
372 int num_cpus = 0;
373 std::string cpu_type;
374 std::string cache_size;
375 while (fgets(line, sizeof(line), cpuinfo) != nullptr) {
376 const char* sep = strchr(line, ':');
377 if (sep == nullptr) {
378 continue;
379 }
380 Slice key = TrimSpace(Slice(line, sep - 1 - line));
381 Slice val = TrimSpace(Slice(sep + 1));
382 if (key == "model name") {
383 ++num_cpus;
384 cpu_type = val.ToString();
385 } else if (key == "cache size") {
386 cache_size = val.ToString();
387 }
388 }
389 fclose(cpuinfo);
390 fprintf(stderr, "CPU: %d * %s\n", num_cpus, cpu_type.c_str());
391 fprintf(stderr, "CPUCache: %s\n", cache_size.c_str());
392 }
393#endif
394 }
395
396 public:
397 Benchmark()

Callers

nothing calls this directly

Calls 4

fopenFunction · 0.85
TrimSpaceFunction · 0.70
SliceClass · 0.50
ToStringMethod · 0.45

Tested by

no test coverage detected