cpu_info_test.cc 614 字节
Newer Older
L
liaogang 已提交
1
#include "paddle/platform/cpu_info.h"
L
liaogang 已提交
2
#include "paddle/string/printf.h"
L
liaogang 已提交
3 4 5 6 7

#include <ostream>
#include <sstream>

#include "gflags/gflags.h"
L
liaogang 已提交
8
#include "glog/logging.h"
L
liaogang 已提交
9 10 11 12 13 14
#include "gtest/gtest.h"

DECLARE_double(fraction_of_cpu_memory_to_use);

TEST(CpuMemoryUsage, Print) {
  std::stringstream ss;
L
liaogang 已提交
15 16 17 18 19 20
  size_t memory_size = paddle::platform::CpuMaxAllocSize() / 1024 / 1024 / 1024;
  float use_percent = FLAGS_fraction_of_cpu_memory_to_use * 100;

  std::cout << paddle::string::Sprintf("\n%.2f %% of CPU Memory Usage: %d GB\n",
                                       use_percent, memory_size)
            << std::endl;
L
liaogang 已提交
21
}