mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
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.
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user