diff options
| author | Martin Hořeňovský | 2019-11-07 12:39:07 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2019-11-14 10:53:12 +0100 |
| commit | d36c15c3caf96c2e751f4ad83a386c1fd047c2f6 (patch) | |
| tree | cba3faef17447ccfd3a2c9a7e751f8a52e2ae226 /examples | |
| parent | 302e2c0b06f131199b97ad33bdebacc359782ff0 (diff) | |
| download | catch3-d36c15c3caf96c2e751f4ad83a386c1fd047c2f6.tar.gz | |
Store tags in one big pre-allocated string and only work with refs
This should decrease the number of allocations before main is entered
significantly, but complicates the code somewhat in return.
Assuming I used `massif` right, doing just `SelfTest --list-tests`
went from 929 allocations at "Remove gcc-4.9 from the travis builds"
(2 commits up), to 614 allocations with this commit.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/210-Evt-EventListeners.cpp | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/examples/210-Evt-EventListeners.cpp b/examples/210-Evt-EventListeners.cpp index d1827807..f9113197 100644 --- a/examples/210-Evt-EventListeners.cpp +++ b/examples/210-Evt-EventListeners.cpp @@ -21,6 +21,10 @@ std::string ws(int const level) { return std::string( 2 * level, ' ' ); } +std::ostream& operator<<(std::ostream& out, Catch::Tag t) { + return out << "original: " << t.original << "lower cased: " << t.lowerCased; +} + template< typename T > std::ostream& operator<<( std::ostream& os, std::vector<T> const& v ) { os << "{ "; @@ -119,31 +123,36 @@ void print( std::ostream& os, int const level, std::string const& title, Catch:: os << ws(level+1) << "- aborting: " << info.aborting << "\n"; } -// struct TestCaseInfo { -// enum SpecialProperties{ -// None = 0, -// IsHidden = 1 << 1, -// ShouldFail = 1 << 2, -// MayFail = 1 << 3, -// Throws = 1 << 4, -// NonPortable = 1 << 5, -// Benchmark = 1 << 6 -// }; +// struct Tag { +// StringRef original, lowerCased; +// }; // -// bool isHidden() const; -// bool throws() const; -// bool okToFail() const; -// bool expectedToFail() const; // -// std::string tagsAsString() const; +// enum class TestCaseProperties : uint8_t { +// None = 0, +// IsHidden = 1 << 1, +// ShouldFail = 1 << 2, +// MayFail = 1 << 3, +// Throws = 1 << 4, +// NonPortable = 1 << 5, +// Benchmark = 1 << 6 +// }; // -// std::string name; -// std::string className; -// std::vector<std::string> tags; -// std::vector<std::string> lcaseTags; -// SourceLineInfo lineInfo; -// SpecialProperties properties; -// }; +// +// struct TestCaseInfo : NonCopyable { +// +// bool isHidden() const; +// bool throws() const; +// bool okToFail() const; +// bool expectedToFail() const; +// +// +// std::string name; +// std::string className; +// std::vector<Tag> tags; +// SourceLineInfo lineInfo; +// TestCaseProperties properties = TestCaseProperties::None; +// }; void print( std::ostream& os, int const level, std::string const& title, Catch::TestCaseInfo const& info ) { os << ws(level ) << title << ":\n" @@ -154,10 +163,9 @@ void print( std::ostream& os, int const level, std::string const& title, Catch:: << ws(level+1) << "- tagsAsString(): '" << info.tagsAsString() << "'\n" << ws(level+1) << "- name: '" << info.name << "'\n" << ws(level+1) << "- className: '" << info.className << "'\n" - << ws(level+1) << "- tags: " << info.tags << "\n" - << ws(level+1) << "- lcaseTags: " << info.lcaseTags << "\n"; + << ws(level+1) << "- tags: " << info.tags << "\n"; print( os, level+1 , "- lineInfo", info.lineInfo ); - os << ws(level+1) << "- properties (flags): 0x" << std::hex << info.properties << std::dec << "\n"; + os << ws(level+1) << "- properties (flags): 0x" << std::hex << static_cast<uint32_t>(info.properties) << std::dec << "\n"; } // struct TestCaseStats { |