online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/// ... ///----------------------------------------------------------------------------| /// https://www.cyberforum.ru/blogs/622334/5875.html#comments ///----------------------------------------------------------------------------| /// Стенд для замера пииисек: ... ///----------------------------------------------------------------------------: #include <stdio.h> //#include <conio.h> #include <string> #include <format> ///----------------------------------------------------------------------------| /// Мерилка тактов проца. ///----------------------------------------------------------------------------: typedef unsigned long long ull; inline ull rdtsc() { unsigned int lo, hi; asm volatile ( "rdtsc\n" : "=a" (lo), "=d" (hi) ); return ((ull)hi << 32) | lo; } ///----------------------------------------------------------------------------| /// Для удобства. ///----------------------------------------------------------------------------: #define START_PERFOMANCE ull t1 = rdtsc(); static ull ss_ = 0xffffffff;\ bool b = false #define END_PERFOMANCE ull v = rdtsc(); v -= t1;\ if(ss_ > v){ b = true; ss_ = v;} ///----------------------------------------------------------------------------| /// Хулиган. ///----------------------------------------------------------------------------: ull CoderHuligan(char* s) { size_t nw = 0; START_PERFOMANCE; std::string fileDest { std::format("{}{}{}", "1234567890+" , "0987654321" , ".png") }; nw = fileDest.size(); END_PERFOMANCE; if(b) { printf ("std::format: %d ", (int)nw); printf ("%10u \n", (unsigned)ss_); b = false; } return ss_; } ///----------------------------------------------------------------------------| /// my. ///----------------------------------------------------------------------------: ull my(char* s) { size_t nw = 0; START_PERFOMANCE; std::string fileDest { "1234567890+"}; fileDest += "0987654321"; fileDest += ".png"; nw = fileDest.size(); END_PERFOMANCE; if(b) { printf ("std::string: %d ", (int)nw); printf ("%10u \n", (unsigned)ss_); b = false; } return ss_; } ///----------------------------------------------------------------------------| /// Наш кролик. ///----------------------------------------------------------------------------: char s[]="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed"; ///----------------------------------------------------------------------------| /// Start. ///----------------------------------------------------------------------------: int main() { ull m,c; //-------------------------------| // Quiet, testing! | //-------------------------------: for(int i = 0; i < 10'000'000; ++i) { c = CoderHuligan(s); m = my (s); } //-------------------------------| // Banners is redy... | //-------------------------------: const char* str[2] = {"WIN <<<--!!!", "looser..."}; int i1, i2; (m > c) ? (i1 = 0, i2 = 1) : (i1 = 1, i2 = 0); //-------------------------------| // Finish result. | //-------------------------------: printf ("\nFinish the race-------------------:\n"); printf ("std::format: %u - ", (unsigned)c); printf ("%s\n", str[i1]); printf ("std::string: %u - ", (unsigned)m); printf ("%s\n", str[i2]); //-------------------------------| // Show efficiency. | //-------------------------------: double ef = 100.0/double(c) * double(m) - 100.0; printf ("\nProfitable std::format: %2.2f%%\n\n", ef); //_getch(); 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