C++ Output Implementations ///// Are there ways to perform faster ?

Правка en42, от SPyofgame, 2020-03-11 17:17:22

---------- Purpose: ----------

  • First, sorry for my bad English.
  • Second, I know there are lots of topics about this. But after solving a problem that need FastIO, I feel interested in FastIO and decide to do the implementations and comparing them. But it maybe time-consuming so I make this post for ones who maybe try to find the Effeciency-Simple-IO, so you can save time instead of searching more.
  • Third, usually it is need not to use FastIO. In the contest, they usually have twice or more time of the solutions code than the given time limitation. Dont worry about faster IO if it is not needed, you should improve your algorithms first, maybe you can use Bitwise Operations for x8 x32 x64 faster.
  • Fourth, if the problem need to be solve in O(n) ~ O(n log n), and your algorithms work in O(n ^ 2), this Micro-Optimization doesnt help you at all (maybe you will get some more points but hard get AC), you should change the algorithms for further approach.
  • Final, for some problems that needed to be solved by FastIO, you can use the suitable template and modify it for your solving the problem. Dont use the template if you dont really know how to use (I may add a guide path to the post in the future)
  • Conclusion, this post is about comparing the implementations for each version of C++ language and you should choose the most suitable for you.

Here are some implementations to output numbers I found

Time to write first 10.000.000 non-negative numbers

(base on Codeforces Custom Test // GNU G++ 17 7.3.0 // GNU G++ 14 6.4.0 // GNU G++ 11 5.1.0)

Sort by GNU G++ 17 7.3.0
Sort by GNU G++ 14 6.4.0
Sort by GNU G++ 11 5.1.0

Time to write 1.000 times first 10000 numbers

(base on Codeforces Custom Test // GNU G++ 17 7.3.0 // GNU G++ 14 6.4.0 // GNU G++ 11 5.1.0)

Sort by GNU G++ 17 7.3.0
Sort by GNU G++ 14 6.4.0
Sort by GNU G++ 11 5.1.0

Time to write first 10.000.000 non-positive numbers

(base on Codeforces Custom Test // GNU G++ 17 7.3.0 // GNU G++ 14 6.4.0 // GNU G++ 11 5.1.0)

Sort by GNU G++ 17 7.3.0
Sort by GNU G++ 14 6.4.0
Sort by GNU G++ 11 5.1.0

Single Line Template

Putchar Non-recursive toString Implementation
Putchar Non-recursive Dividing Implementation
Putchar Reverse Implementation
Putchar Recursive Implementation
Unlocked-Putchar Non-recursive toString Implementation
Unlocked-Putchar Non-recursive Dividing Implementation
Unlocked-Putchar Reverse Implementation
Unlocked-Putchar Recursive Implementation
Printf Implementation
synchronized(off) Implementation
synchronized(true) Implementation
Cout Implementation
fwrite buffer Implementation

---------- About: ----------

---------- Similiar Topic: ----------

---------- Planning: ----------

  • Test about random 10.000.000 big numbers
  • Test with Microsoft Visual C++ 2010
  • Test with Microsoft Visual C++ 2017
  • More implementations (Actually the post is about Faster and Faster Short Output Implementation but I will add some for speed comparing)
  • New output types (long long, double, string)
Теги #c++

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en44 Английский SPyofgame 2020-06-06 17:24:10 2 Tiny change: '\n\n\n\n\n' -> '\n\n\n\n\n\n'
en43 Английский SPyofgame 2020-06-01 04:54:23 24664 Add Sort by Microsoft Visual C++ 2010 | Add Sort by Microsoft Visual C++ 2017
en42 Английский SPyofgame 2020-03-11 17:17:22 246
en41 Английский SPyofgame 2020-03-11 17:16:30 585
en40 Английский SPyofgame 2020-03-11 17:07:19 1028
en39 Английский SPyofgame 2020-03-11 16:19:02 5 Tiny change: '\n- _[C++ Output Implem' -> '\n- _[C++ Input Implem'
en38 Английский SPyofgame 2020-03-11 16:17:54 828
en37 Английский SPyofgame 2020-03-11 16:00:33 163
en36 Английский SPyofgame 2020-03-11 15:32:22 3
en35 Английский SPyofgame 2020-03-11 13:43:24 46 Tiny change: '-- \n\n- _Test ' -> '-- \n\n- _Start working on `Input Implementation`_\n- _Test '
en34 Английский SPyofgame 2020-03-11 12:13:31 13359
en33 Английский SPyofgame 2020-03-10 17:02:27 66
en32 Английский SPyofgame 2020-03-10 16:57:31 2020
en31 Английский SPyofgame 2020-03-10 16:45:15 17395
en30 Английский SPyofgame 2020-03-10 15:13:24 436
en29 Английский SPyofgame 2020-03-10 15:04:53 11184
en28 Английский SPyofgame 2020-03-09 17:08:42 23 Tiny change: '_\n- _New type of implementations (long lo' -> '_\n- _New output types (long lo'
en27 Английский SPyofgame 2020-03-09 17:08:00 107
en26 Английский SPyofgame 2020-03-09 17:04:42 56
en25 Английский SPyofgame 2020-03-09 17:02:11 259 Tiny change: ' 14 6.4.0`_\n- _Test' -> ' 14 6.4.0` for who_\n- _Test'
en24 Английский SPyofgame 2020-03-08 14:31:46 1 Tiny change: 'ementation to output' -> 'ementations to output'
en23 Английский SPyofgame 2020-03-08 13:35:10 56
en22 Английский SPyofgame 2020-03-08 13:34:24 62
en21 Английский SPyofgame 2020-03-08 13:32:27 151
en20 Английский SPyofgame 2020-03-08 13:31:05 22
en19 Английский SPyofgame 2020-03-08 13:30:04 643
en18 Английский SPyofgame 2020-03-08 13:23:01 2 Tiny change: 't[buf_len]. buf_num[b' -> 't[buf_len], buf_num[b'
en17 Английский SPyofgame 2020-03-08 13:21:59 2393
en16 Английский SPyofgame 2020-03-08 06:24:35 1405
en15 Английский SPyofgame 2020-03-08 05:43:13 2610
en14 Английский SPyofgame 2020-03-07 21:43:54 1881
en13 Английский SPyofgame 2020-03-07 21:05:24 16
en12 Английский SPyofgame 2020-03-07 21:00:12 68
en11 Английский SPyofgame 2020-03-07 17:34:09 40
en10 Английский SPyofgame 2020-03-07 13:05:13 3986
en9 Английский SPyofgame 2020-03-07 12:49:33 421
en8 Английский SPyofgame 2020-03-07 12:34:04 128
en7 Английский SPyofgame 2020-03-07 12:32:50 28
en6 Английский SPyofgame 2020-03-07 12:32:25 200
en5 Английский SPyofgame 2020-03-07 12:17:57 217
en4 Английский SPyofgame 2020-03-07 12:16:16 502
en3 Английский SPyofgame 2020-03-07 12:12:35 9
en2 Английский SPyofgame 2020-03-07 12:11:11 16 Tiny change: ' summary="Third Implement' -> ' summary="synchronized(off) Implement'
en1 Английский SPyofgame 2020-03-07 12:10:26 2318 Initial revision (published)