Skip to content

Commit

Permalink
watchman: migrate pending_test to gtest
Browse files Browse the repository at this point in the history
Summary: as above

Reviewed By: pkaush

Differential Revision: D17775683

fbshipit-source-id: 701ee6ec9da60d850919c0bc5f41a98578ae637c
  • Loading branch information
wez authored and facebook-github-bot committed Oct 10, 2019
1 parent 4a71ae7 commit 367e93c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ gtest_discover_tests(art.t)
t_test(ignore tests/ignore_test.cpp tests/log_stub.cpp)
gtest_discover_tests(ignore.t)
t_test(pending tests/pending_test.cpp tests/log_stub.cpp)
gtest_discover_tests(pending.t)
t_test(string tests/string_test.cpp tests/log_stub.cpp)
t_test(log tests/log.cpp)
t_test(bser tests/bser.cpp tests/log_stub.cpp)
Expand Down
23 changes: 8 additions & 15 deletions tests/pending_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Licensed under the Apache License, Version 2.0. */

#include "watchman.h"
#include "thirdparty/tap.h"
#include <folly/logging/xlog.h>
#include <folly/portability/GTest.h>

static void build_list(
std::vector<watchman_pending_fs>* list,
Expand Down Expand Up @@ -39,7 +40,7 @@ size_t process_items(PendingCollection::LockedPtr& coll) {
}

// Simulate
static void bench_pending(void) {
TEST(Pending, bench) {
// These parameters give us 262140 items to track
const size_t tree_depth = 7;
const size_t num_files_per_dir = 8;
Expand All @@ -60,7 +61,7 @@ static void bench_pending(void) {
tree_depth,
num_files_per_dir,
num_dirs_per_dir);
diag("built list with %u items", list.size());
XLOG(ERR) << "built list with " << list.size() << " items";

// Benchmark insertion in top-down order.
{
Expand All @@ -75,8 +76,8 @@ static void bench_pending(void) {
drained = process_items(lock);

gettimeofday(&end, NULL);
diag("took %.3fs to insert %u items into pending coll",
w_timeval_diff(start, end), drained);
XLOG(ERR) << "took " << w_timeval_diff(start, end) << "s to insert "
<< drained << " items into pending coll";
}

// and now in reverse order; this is from the leaves of the filesystem
Expand All @@ -96,15 +97,7 @@ static void bench_pending(void) {
drained = process_items(lock);

gettimeofday(&end, NULL);
diag("took %.3fs to reverse insert %u items into pending coll",
w_timeval_diff(start, end), drained);
XLOG(ERR) << "took " << w_timeval_diff(start, end) << "s to reverse insert "
<< drained << " items into pending coll";
}
}

int main(int, char**) {
plan_tests(1);
bench_pending();
pass("got here");

return exit_status();
}

0 comments on commit 367e93c

Please sign in to comment.