Added benchmark for previous commit, added iterations to failure bench.

This commit is contained in:
Martin Hořeňovský 2017-01-15 10:06:18 +01:00
parent 3b98a0166f
commit 83f4b39680
3 changed files with 6 additions and 5 deletions

View File

@ -10,21 +10,19 @@
#include "catch_common.h" #include "catch_common.h"
#include <algorithm>
namespace Catch { namespace Catch {
bool startsWith( std::string const& s, std::string const& prefix ) { bool startsWith( std::string const& s, std::string const& prefix ) {
return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
} }
bool startsWith( std::string const& s, char prefix ) { bool startsWith( std::string const& s, char prefix ) {
return !s.empty() && s.front() == prefix; return !s.empty() && s[0] == prefix;
} }
bool endsWith( std::string const& s, std::string const& suffix ) { bool endsWith( std::string const& s, std::string const& suffix ) {
return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin());
} }
bool endsWith( std::string const& s, char suffix ) { bool endsWith( std::string const& s, char suffix ) {
return !s.empty() && s.back() == suffix; return !s.empty() && s[s.size()-1] == suffix;
} }
bool contains( std::string const& s, std::string const& infix ) { bool contains( std::string const& s, std::string const& infix ) {
return s.find( infix ) != std::string::npos; return s.find( infix ) != std::string::npos;

View File

@ -28,7 +28,7 @@ TEST_CASE("Successful tests -- CHECK", "[Success]") {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
TEST_CASE("Unsuccessful tests -- CHECK", "[Failure]") { TEST_CASE("Unsuccessful tests -- CHECK", "[Failure]") {
const size_t sz = 128 * 1024; const size_t sz = 1024 * 1024;
std::vector<size_t> vec; vec.reserve(sz); std::vector<size_t> vec; vec.reserve(sz);

View File

@ -0,0 +1,3 @@
Successful tests -- CHECK: median: 1.2982 (s), stddev: 0.019540648829214084 (s)
Successful tests -- REQUIRE: median: 1.30102 (s), stddev: 0.014758430547392974 (s)
Unsuccessful tests -- CHECK: median: 15.520199999999999 (s), stddev: 0.09536359426485094 (s)