proxygen
FBStringBenchmark.cpp File Reference
#include <folly/FBString.h>
#include <cstdlib>
#include <fstream>
#include <list>
#include <sstream>
#include <boost/random.hpp>
#include <folly/Benchmark.h>
#include <folly/Random.h>
#include <folly/container/Foreach.h>
#include <folly/portability/GFlags.h>
#include <folly/test/FBStringTestBenchmarks.cpp.h>

Go to the source code of this file.

Macros

#define CONCAT(A, B)   CONCAT_HELPER(A, B)
 
#define CONCAT_HELPER(A, B)   A##B
 
#define BENCHFUN(F)   CONCAT(CONCAT(BM_, F), CONCAT(_, STRING))
 
#define STRING   string
 
#define STRING   fbstring
 

Typedefs

typedef boost::mt19937 RandomT
 

Functions

static RandomT rng (seed)
 
template<class Integral1 , class Integral2 >
Integral2 random (Integral1 low, Integral2 up)
 
template<class String >
void randomString (String *toFill, size_t size=1000)
 
template<class String >
void randomBinaryString (String *toFill, size_t size=1000)
 
template<class String , class Integral >
void Num2String (String &str, Integral n)
 
std::list< char > RandomList (unsigned int maxSize)
 
int main (int argc, char **argv)
 

Variables

static const int seed = folly::randomNumberSeed()
 

Macro Definition Documentation

#define CONCAT (   A,
  B 
)    CONCAT_HELPER(A, B)

Definition at line 77 of file FBStringBenchmark.cpp.

#define CONCAT_HELPER (   A,
  B 
)    A##B

Definition at line 78 of file FBStringBenchmark.cpp.

#define STRING   fbstring

Definition at line 84 of file FBStringBenchmark.cpp.

Typedef Documentation

typedef boost::mt19937 RandomT

Definition at line 38 of file FBStringBenchmark.cpp.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 88 of file FBStringBenchmark.cpp.

References folly::runBenchmarks().

88  {
89  gflags::ParseCommandLineFlags(&argc, &argv, true);
91  return 0;
92 }
void runBenchmarks()
Definition: Benchmark.cpp:456
char ** argv
template<class Integral1 , class Integral2 >
Integral2 random ( Integral1  low,
Integral2  up 
)

Definition at line 42 of file FBStringBenchmark.cpp.

References folly::gen::range(), and rng().

Referenced by clause11_21_4_2_d(), clause11_21_4_2_e(), clause11_21_4_2_f(), clause11_21_4_2_g(), clause11_21_4_2_j(), clause11_21_4_2_k(), clause11_21_4_2_l(), clause11_21_4_2_lprime(), clause11_21_4_2_m(), clause11_21_4_5(), clause11_21_4_6_1(), clause11_21_4_6_2(), clause11_21_4_6_3_b(), clause11_21_4_6_3_c(), clause11_21_4_6_3_e(), clause11_21_4_6_3_h(), clause11_21_4_6_3_i(), clause11_21_4_6_4(), clause11_21_4_6_5(), clause11_21_4_6_6(), clause11_21_4_6_7(), clause11_21_4_7_2_a(), clause11_21_4_7_2_a1(), clause11_21_4_7_2_a2(), clause11_21_4_7_2_b(), clause11_21_4_7_2_b1(), clause11_21_4_7_2_b2(), clause11_21_4_7_2_c(), clause11_21_4_7_2_c1(), clause11_21_4_7_2_c2(), clause11_21_4_7_2_d(), clause11_21_4_7_3_a(), clause11_21_4_7_3_b(), clause11_21_4_7_3_c(), clause11_21_4_7_3_d(), clause11_21_4_7_4_a(), clause11_21_4_7_4_b(), clause11_21_4_7_4_c(), clause11_21_4_7_4_d(), clause11_21_4_7_5_a(), clause11_21_4_7_5_b(), clause11_21_4_7_5_c(), clause11_21_4_7_5_d(), clause11_21_4_7_6_a(), clause11_21_4_7_6_b(), clause11_21_4_7_6_c(), clause11_21_4_7_6_d(), clause11_21_4_7_7_a(), clause11_21_4_7_7_b(), clause11_21_4_7_7_c(), clause11_21_4_7_7_d(), clause11_21_4_7_8(), clause11_21_4_7_9_b(), clause11_21_4_7_9_c(), clause11_21_4_7_9_e(), clause11_21_4_8_1_g(), clause11_21_4_8_1_h(), clause11_21_4_8_1_k(), findSuccessful(), fizz::RandomGenerator< Size >::generateRandom(), fizz::RandomNumGenerator< T, typename >::generateRandom(), fizz::sm::getClientHello(), fizz::sm::getEarlyDataParams(), operator<<(), testing::internal::PrintOnOneLine(), randomBinaryString(), RandomList(), randomString(), replace(), reserve(), resize(), fizz::test::MockFactory::setDefaults(), fizz::client::test::ClientProtocolTest::setupExpectingServerHello(), testing::TestCase::ShouldRunTest(), testing::internal::TearDownEnvironment(), fizz::test::TEST(), TEST(), fizz::client::test::TEST_F(), fizz::server::test::TEST_F(), TestDeltas(), TESTFUN(), and testing::internal::GTestFlagSaver::~GTestFlagSaver().

42  {
43  boost::uniform_int<> range(low, up);
44  return range(rng);
45 }
Gen range(Value begin, Value end)
Definition: Base.h:467
static RandomT rng(seed)
template<class String >
void randomBinaryString ( String *  toFill,
size_t  size = 1000 
)

Definition at line 55 of file FBStringBenchmark.cpp.

References FOR_EACH, i, random(), and folly::size().

Referenced by equality().

55  {
56  assert(toFill);
57  toFill->resize(size);
58  FOR_EACH (i, *toFill) { *i = random('0', '1'); }
59 }
Integral2 random(Integral1 low, Integral2 up)
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define FOR_EACH(i, c)
Definition: Foreach.h:143
std::list<char> RandomList ( unsigned int  maxSize)

Definition at line 68 of file FBStringBenchmark.cpp.

References i, and random().

Referenced by clause11_21_4_6_2(), clause11_21_4_6_3_f(), and clause11_21_4_6_4().

68  {
69  std::list<char> lst(random(0u, maxSize));
70  std::list<char>::iterator i = lst.begin();
71  for (; i != lst.end(); ++i) {
72  *i = random('a', 'z');
73  }
74  return lst;
75 }
Integral2 random(Integral1 low, Integral2 up)
template<class String >
void randomString ( String *  toFill,
size_t  size = 1000 
)

Definition at line 48 of file FBStringBenchmark.cpp.

References FOR_EACH, i, random(), and folly::size().

Referenced by assignmentOp(), clause11_21_4_6_1(), clause11_21_4_6_2(), clause11_21_4_6_3_a(), clause11_21_4_6_3_b(), clause11_21_4_6_3_c(), clause11_21_4_6_3_d(), clause11_21_4_6_3_e(), clause11_21_4_6_4(), clause11_21_4_6_6(), clause11_21_4_6_8(), clause11_21_4_7_1(), clause11_21_4_7_4_a(), clause11_21_4_7_4_b(), clause11_21_4_7_4_c(), clause11_21_4_7_5_a(), clause11_21_4_7_5_b(), clause11_21_4_7_5_c(), clause11_21_4_7_6_a(), clause11_21_4_7_6_b(), clause11_21_4_7_6_c(), clause11_21_4_7_7_a(), clause11_21_4_7_7_b(), clause11_21_4_7_7_c(), clause11_21_4_7_9_a(), clause11_21_4_7_9_b(), clause11_21_4_7_9_c(), clause11_21_4_7_9_d(), clause11_21_4_7_9_e(), clause11_21_4_8_1_a(), clause11_21_4_8_1_b(), clause11_21_4_8_1_c(), clause11_21_4_8_1_d(), clause11_21_4_8_1_e(), clause11_21_4_8_1_f(), clause11_21_4_8_1_g(), clause11_21_4_8_1_h(), clause11_21_4_8_1_i(), clause11_21_4_8_1_j(), clause11_21_4_8_1_k(), clause11_21_4_8_1_l(), copyCtor(), ctorFromArray(), getline(), replace(), and TEST().

48  {
49  assert(toFill);
50  toFill->resize(size);
51  FOR_EACH (i, *toFill) { *i = random('a', 'z'); }
52 }
Integral2 random(Integral1 low, Integral2 up)
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define FOR_EACH(i, c)
Definition: Foreach.h:143
static RandomT rng ( seed  )
static

Referenced by random().

Variable Documentation