2014-04-21 19:29:55 +00:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
2014-04-21 20:01:50 +00:00
|
|
|
#include "util/benchharness.h"
|
2014-04-21 19:29:55 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
BENCHMARK(insertFrontVector) {
|
2014-11-11 21:47:22 +00:00
|
|
|
std::vector<size_t> v;
|
|
|
|
for (size_t i = 0; i < 100; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.begin(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_RELATIVE(insertBackVector) {
|
2014-11-11 21:47:22 +00:00
|
|
|
std::vector<size_t> v;
|
2014-04-29 19:29:22 +00:00
|
|
|
for (size_t i = 0; i < 100; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.end(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_N(insertFrontVector_n, n) {
|
2014-11-11 21:47:22 +00:00
|
|
|
std::vector<size_t> v;
|
2014-04-29 19:29:22 +00:00
|
|
|
for (size_t i = 0; i < n; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.begin(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_RELATIVE_N(insertBackVector_n, n) {
|
2014-11-11 21:47:22 +00:00
|
|
|
std::vector<size_t> v;
|
2014-04-29 19:29:22 +00:00
|
|
|
for (size_t i = 0; i < n; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.end(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_N(insertFrontEnd_n, n) {
|
2014-11-11 21:47:22 +00:00
|
|
|
std::vector<size_t> v;
|
2014-04-29 19:29:22 +00:00
|
|
|
for (size_t i = 0; i < n; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.begin(), i);
|
|
|
|
}
|
2014-04-29 19:29:22 +00:00
|
|
|
for (size_t i = 0; i < n; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.end(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_RELATIVE_N(insertFrontEndSuspend_n, n) {
|
2014-11-11 21:47:22 +00:00
|
|
|
std::vector<size_t> v;
|
2014-04-29 19:29:22 +00:00
|
|
|
for (size_t i = 0; i < n; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.begin(), i);
|
|
|
|
}
|
|
|
|
BENCHMARK_SUSPEND {
|
2014-04-29 19:29:22 +00:00
|
|
|
for (size_t i = 0; i < n; i++) {
|
2014-04-21 19:29:55 +00:00
|
|
|
v.insert(v.end(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
rocksdb::benchmark::RunBenchmarks();
|
|
|
|
return 0;
|
|
|
|
}
|