@anonymous/

RevolvingGoodGlitches

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <iostream>
#include <chrono>
#include <unistd.h>
#include <thread>

void clearScreen(){
    std::cout << std::endl;
    // #ifdef _WIN32
    //     system("cls");
    // #else
    //     system("clear");
    // #endif
}

double testCout()
{
    clearScreen();
    
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    auto start = std::chrono::high_resolution_clock::now();
    for (int j = 0; j != 10000; ++j)
        std::cout << "abcdef";
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double, std::milli> delta=  end - start;
    return delta.count();
    
}

double testPrintf()
{
    clearScreen();

    auto start = std::chrono::high_resolution_clock::now();
    for (int j = 0; j != 10000; ++j)
        printf("abcdef");
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double, std::milli> delta=  end - start;
    return delta.count();
}

int main(){
    double a=  testCout();
   double b=   testPrintf();
   
    std::cout << std::endl;
     std::this_thread::sleep_for(std::chrono::seconds(1));
    std::cout << a << "\n" << b << std::endl;
    return 0;
}