mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 02:44:18 +00:00
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
|
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
||
|
// This source code is licensed under the BSD-style license found in the
|
||
|
// LICENSE file in the root directory of this source tree. An additional grant
|
||
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||
|
//
|
||
|
|
||
|
#include "util/benchmarkharness.h"
|
||
|
#include <vector>
|
||
|
|
||
|
namespace rocksdb {
|
||
|
namespace benchmark {
|
||
|
|
||
|
BENCHMARK(insertFrontVector) {
|
||
|
std::vector<int> v;
|
||
|
for (int i = 0; i < 100; i++) {
|
||
|
v.insert(v.begin(), i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BENCHMARK_RELATIVE(insertBackVector) {
|
||
|
std::vector<int> v;
|
||
|
for (int i = 0; i < 100; i++) {
|
||
|
v.insert(v.end(), i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BENCHMARK_N(insertFrontVector_n, n) {
|
||
|
std::vector<int> v;
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
v.insert(v.begin(), i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BENCHMARK_RELATIVE_N(insertBackVector_n, n) {
|
||
|
std::vector<int> v;
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
v.insert(v.end(), i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BENCHMARK_N(insertFrontEnd_n, n) {
|
||
|
std::vector<int> v;
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
v.insert(v.begin(), i);
|
||
|
}
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
v.insert(v.end(), i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BENCHMARK_RELATIVE_N(insertFrontEndSuspend_n, n) {
|
||
|
std::vector<int> v;
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
v.insert(v.begin(), i);
|
||
|
}
|
||
|
BENCHMARK_SUSPEND {
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
v.insert(v.end(), i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
} // namespace benchmark
|
||
|
} // namespace rocksdb
|
||
|
|
||
|
int main(int argc, char** argv) {
|
||
|
rocksdb::benchmark::RunBenchmarks();
|
||
|
return 0;
|
||
|
}
|