diff --git a/libtermbench/termbench.cpp b/libtermbench/termbench.cpp index 0d9f0e3..a748754 100644 --- a/libtermbench/termbench.cpp +++ b/libtermbench/termbench.cpp @@ -212,16 +212,27 @@ class ManyLines: public Test public: ManyLines() noexcept: Test("many_lines", "") {} - void run(Buffer& _sink) noexcept override + void setup(unsigned short, unsigned short) override { - while (_sink.good()) + text.resize(4 * 1024 * 1024); + for (auto i = text.data(), e = i + text.size(); i != e; ++i) { char const value = randomAsciiChar(); - writeChar(_sink, value); - if (value % 26 == 0) - _sink.write("\n"sv); + if (value % 26 != 0) + *i = value; + else + *i = '\n'; } } + + void run(Buffer& _sink) noexcept override + { + while (_sink.good()) + _sink.write(text); + } + +private: + std::string text; }; class LongLines: public Test @@ -318,11 +329,24 @@ class Binary: public Test public: Binary() noexcept: Test("binary", "") {} + void setup(unsigned short, unsigned short) override + { + text.resize(4 * 1024 * 1024); + for (auto i = text.data(), e = i + text.size(); i != e; ++i) + { + char const value = randomAsciiChar(); + if (value % 26 != 0) + *i = value; + else + *i = '\n'; + } + } + void run(Buffer& _sink) noexcept override { while (_sink.good()) { - writeChar(_sink, static_cast(rand() % 256)); + _sink.write(text); } } @@ -330,6 +354,9 @@ class Binary: public Test { _sink.write("\033c"); } + +private: + std::string text; }; } diff --git a/libtermbench/termbench.h b/libtermbench/termbench.h index 2bfa187..366e8ad 100644 --- a/libtermbench/termbench.h +++ b/libtermbench/termbench.h @@ -76,9 +76,9 @@ struct Test description{_description} {} - virtual void setup(unsigned short, unsigned short) noexcept {} + virtual void setup(unsigned short, unsigned short) {} virtual void run(Buffer&) noexcept = 0; - virtual void teardown(Buffer&) noexcept {} + virtual void teardown(Buffer&) {} }; struct Result