online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <string> #include <string_view> #include <utility> #include <vector> #include <chrono> template<typename T> void test (std::string_view name, T const& s, int count) { std::cout << "[" << name << "]:\n"; std::vector<T> result; namespace cho = std::chrono; auto start = cho::system_clock::now(); for (auto i=0; i<count; i++) { auto s1 = s.substr(10); auto s2 = s.substr(5, 3); auto s3 = s.substr(s.size() - 3, 50); result.push_back(std::move(s1)); result.push_back(std::move(s2)); result.push_back(std::move(s3)); } auto ms = cho::duration_cast<cho::milliseconds>(cho::system_clock::now() - start); std::cout << result[0] << "," << result[count / 3] << "," << result[count / 2] << "," << result[count * 2 / 3] << "," << result[count / 2] << "," << result[count] << "," << result[count * 2] << "," << result[count * 3 - 1] << "\n"; std::cout << ms.count() << std::endl; } int main() { int const count = 10'000'000; std::string data = "0123456789abcdefghij"; { test("string_data", data, count); } { test("string_view", std::string_view{data}, count); } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue