fork download
#include <iostream>
#include <cctype>
#include <ctime>
#include <string>

int main()
{
    clock_t time;
    
    std::string str("qWeRtY uIoP[  ]A   SdfghJklk;'ZXcvbcxMMMBNBM,./dsadsdas");
    std::string dump(str);
    
    time = clock();
    
    for (long i = 0; i < 2000000; ++i)
    {
        str = dump;
        for (auto &c : str)
        {
            if (isalpha(c))
                c ^= 32;
        }
    }
    
    std::cout << (double)time / CLOCKS_PER_SEC << std::endl;
    
    time = clock();
    
    for (long i = 0; i < 2000000; ++i)
    {
        str = dump;
        for (auto &c : str)
        {
            if (isupper(c))
            {
                c = tolower(c);
            }
            else
            {
                if (islower(c))
                {
                    c = toupper(c);
                }
            }
        }
    }
    
    std::cout << (double)time / CLOCKS_PER_SEC << std::endl;
    
}
Success #stdin #stdout 4.72s 3028KB
stdin
Standard input is empty
stdout
0
1.5