Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <time.h>
- #include <stdint.h>
- #include <iostream>
- /*
- sla@sla-Inspiron-5720:~$ ./ios > /dev/null
- 44294
- 39727
- 71075
- 130222
- sla@sla-Inspiron-5720:~$ ./ios > /dev/null
- 42322
- 39617
- 73667
- 134513
- sla@sla-Inspiron-5720:~$ ./ios > /dev/null
- 53560
- 41909
- 74061
- 132310
- sla@sla-Inspiron-5720:~$ ./ios > ~/123.txt
- 69455
- 157903
- 199676
- 284772
- sla@sla-Inspiron-5720:~$ ./ios > ~/123.txt
- 68343
- 180498
- 170306
- 204986
- *
- */
- static uint32_t getTick() {
- timespec ts;
- unsigned theTick = 0U;
- clock_gettime( CLOCK_REALTIME, &ts );
- theTick = ts.tv_nsec / 1000;
- theTick += ts.tv_sec * 1000000;
- return theTick;
- }
- int main() {
- uint32_t tc;
- //---------------------------------
- std::ios::sync_with_stdio(false);
- tc = getTick();
- for(int i = 0; i < 1000000; ++i)
- {
- std::cout << "1234567890ABCDEF";
- }
- tc = getTick() - tc;
- std::cerr << tc << std::endl;
- //---------------------------------
- std::ios::sync_with_stdio(true);
- tc = getTick();
- for(int i = 0; i < 1000000; ++i)
- {
- std::cout << "1234567890ABCDEF";
- }
- tc = getTick() - tc;
- std::cerr << tc << std::endl;
- //---------------------------------
- tc = getTick();
- for(int i = 0; i < 1000000; ++i)
- {
- printf("1234567890ABCDEF");
- }
- tc = getTick() - tc;
- std::cerr << tc << std::endl;
- //---------------------------------
- tc = getTick();
- for(int i = 0; i < 1000000; ++i)
- {
- printf("%s", "1234567890ABCDEF");
- }
- tc = getTick() - tc;
- std::cerr << tc << std::endl;
- //---------------------------------
- //---------------------------------
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement