diff options
author | A. Unique TensorFlower <nobody@tensorflow.org> | 2016-02-17 12:53:37 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-02-17 12:56:52 -0800 |
commit | 73f11ec7d1cd7ac3e4b1455334b73791b2a64c81 (patch) | |
tree | 9124546c0c05994cd909bafe92267b6d0a72234f | |
parent | fe056f0b5e52db86766761f5e6446a89c1aa3938 (diff) |
Duplicated the same benchmark for the cpu allocator.
CPU: Intel Ivybridge with HyperThreading (6 cores) dL1:32KB dL2:256KB dL3:12MB
Benchmark Time(ns) CPU(ns) Iterations
----------------------------------------------
BM_Allocation 86 86 81988374
Change: 114889533
-rw-r--r-- | tensorflow/core/framework/allocator_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tensorflow/core/framework/allocator_test.cc b/tensorflow/core/framework/allocator_test.cc index 52cb7a8e56..e45c85ddc1 100644 --- a/tensorflow/core/framework/allocator_test.cc +++ b/tensorflow/core/framework/allocator_test.cc @@ -14,10 +14,14 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/core/framework/allocator.h" + #include <algorithm> #include <vector> + #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/test.h" +#include "tensorflow/core/platform/test_benchmark.h" + namespace tensorflow { TEST(CPUAllocatorTest, Simple) { @@ -94,4 +98,18 @@ TEST(CustomAllocatorAttributes, TestSetterAndGetter) { EXPECT_FALSE(HasDeviceAllocatorAttribute(AllocatorAttributes())); } +static void BM_Allocation(int iters) { + Allocator* a = cpu_allocator(); + // Exercise a few different allocation sizes + std::vector<int> sizes = {256, 4096, 16384, 524288, 512, 1048576}; + int size_index = 0; + + while (--iters > 0) { + int bytes = sizes[size_index++ % sizes.size()]; + void* p = a->AllocateRaw(1, bytes); + a->DeallocateRaw(p); + } +} +BENCHMARK(BM_Allocation); + } // namespace tensorflow |