From: Yedidya Feldblum Date: Tue, 2 Jan 2018 00:46:40 +0000 (-0800) Subject: Fix copyright lines for Bits.h and move BitsBenchmark.cpp X-Git-Tag: v2018.01.08.00~23 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=337e3b8a157210eea33c88361b5e4c45a5efc462;hp=454829ac74176c4caf834ebd2b5c8a941fdf9d7f Fix copyright lines for Bits.h and move BitsBenchmark.cpp Summary: [Folly] Fix copyright lines for `Bits.h` and move `BitsBenchmark.cpp`. Reviewed By: spalamarchuk Differential Revision: D6648828 fbshipit-source-id: 5eed558ac2d47a1497d64173bc84a4ca27d79764 --- diff --git a/folly/lang/Bits.h b/folly/lang/Bits.h index 889b3a0b..b0af3714 100644 --- a/folly/lang/Bits.h +++ b/folly/lang/Bits.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Facebook, Inc. + * Copyright 2011-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/folly/lang/test/BitsBenchmark.cpp b/folly/lang/test/BitsBenchmark.cpp new file mode 100644 index 00000000..754cf00d --- /dev/null +++ b/folly/lang/test/BitsBenchmark.cpp @@ -0,0 +1,69 @@ +/* + * Copyright 2016-present Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// @author Tudor Bosman (tudorb@fb.com) + +#include + +#include + +using namespace folly; + +BENCHMARK(nextPowTwoClz, iters) { + for (unsigned long i = 0; i < iters; ++i) { + auto x = folly::nextPowTwo(iters); + folly::doNotOptimizeAway(x); + } +} + +BENCHMARK_DRAW_LINE(); +BENCHMARK(isPowTwo, iters) { + bool b; + for (unsigned long i = 0; i < iters; ++i) { + b = folly::isPowTwo(i); + folly::doNotOptimizeAway(b); + } +} + +BENCHMARK_DRAW_LINE(); +BENCHMARK(reverse, iters) { + uint64_t b = 0; + for (unsigned long i = 0; i < iters; ++i) { + b = folly::bitReverse(i + b); + folly::doNotOptimizeAway(b); + } +} + +int main(int argc, char** argv) { + gflags::ParseCommandLineFlags(&argc, &argv, true); + folly::runBenchmarks(); + return 0; +} + +/* +Benchmarks run on dual Xeon X5650's @ 2.67GHz w/hyperthreading enabled + (12 physical cores, 12 MB cache, 72 GB RAM) + +============================================================================ +folly/test/BitsBenchmark.cpp relative time/iter iters/s +============================================================================ +nextPowTwoClz 0.00fs Infinity +---------------------------------------------------------------------------- +isPowTwo 731.61ps 1.37G +---------------------------------------------------------------------------- +reverse 4.84ns 206.58M +============================================================================ +*/ diff --git a/folly/lang/test/BitsTest.cpp b/folly/lang/test/BitsTest.cpp index e2708f8b..2619befd 100644 --- a/folly/lang/test/BitsTest.cpp +++ b/folly/lang/test/BitsTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2017 Facebook, Inc. + * Copyright 2011-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/folly/test/BitsBenchmark.cpp b/folly/test/BitsBenchmark.cpp deleted file mode 100644 index da0cab43..00000000 --- a/folly/test/BitsBenchmark.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2017 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// @author Tudor Bosman (tudorb@fb.com) - -#include - -#include - -using namespace folly; - -BENCHMARK(nextPowTwoClz, iters) { - for (unsigned long i = 0; i < iters; ++i) { - auto x = folly::nextPowTwo(iters); - folly::doNotOptimizeAway(x); - } -} - -BENCHMARK_DRAW_LINE(); -BENCHMARK(isPowTwo, iters) { - bool b; - for (unsigned long i = 0; i < iters; ++i) { - b = folly::isPowTwo(i); - folly::doNotOptimizeAway(b); - } -} - -BENCHMARK_DRAW_LINE(); -BENCHMARK(reverse, iters) { - uint64_t b = 0; - for (unsigned long i = 0; i < iters; ++i) { - b = folly::bitReverse(i + b); - folly::doNotOptimizeAway(b); - } -} - -int main(int argc, char** argv) { - gflags::ParseCommandLineFlags(&argc, &argv, true); - folly::runBenchmarks(); - return 0; -} - -/* -Benchmarks run on dual Xeon X5650's @ 2.67GHz w/hyperthreading enabled - (12 physical cores, 12 MB cache, 72 GB RAM) - -============================================================================ -folly/test/BitsBenchmark.cpp relative time/iter iters/s -============================================================================ -nextPowTwoClz 0.00fs Infinity ----------------------------------------------------------------------------- -isPowTwo 731.61ps 1.37G ----------------------------------------------------------------------------- -reverse 4.84ns 206.58M -============================================================================ -*/ diff --git a/folly/test/Makefile.am b/folly/test/Makefile.am index 9a47a30b..9fb035f0 100644 --- a/folly/test/Makefile.am +++ b/folly/test/Makefile.am @@ -162,7 +162,7 @@ math_test_SOURCES = MathTest.cpp math_test_LDADD = libfollytestmain.la $(top_builddir)/libfollybenchmark.la TESTS += math_test -bits_test_SOURCES = BitsTest.cpp +bits_test_SOURCES = ../lang/test/BitsTest.cpp bits_test_LDADD = libfollytestmain.la $(top_builddir)/libfollybenchmark.la TESTS += bits_test