내가 사용 중인 언어와 나중에 배울 언어인 파이썬 출력 속도 출력 속도 비교 표를 퍼왔다.
하지만 알고리즘에 따라서 속도는 더 줄어들 수도 늘어날 수도 있다.
그러니 그냥 참고정도로만 보자
순위 | 출력방법 | 평균(초) |
---|---|---|
1 | BufferedWriter, bf.write(i + "\n"); | 0.9581 |
2 | StringBuilder를 이용해 문자열 하나로 만든 다음, System.out.println(sb); | 1.1881 |
3 | BufferedWriter, bf.write(Integer.toString(i)); bf.newLine(); | 1.2556 |
4 | PrintWriter | 1.954 |
5 | System.out.println(i); | 30.013 |
순위 | 언어 | 출력방법 | 평균(초) |
---|---|---|---|
1 | PyPy | for i in xrange(1,n+1): sys.stdout.write(str(i)+'\n') | 0.9847 |
2 | PyPy3 | for i in range(1,n+1): sys.stdout.write(str(i)+'\n') | 1.3722 |
3 | PyPy | print '\n'.join(map(str,xrange(1,n+1))) | 1.3738 |
4 | PyPy | sys.stdout.write('\n'.join(map(str,xrange(1,n+1)))) | 1.3772 |
5 | PyPy | for i in xrange(1,n+1): print i | 1.4968 |
6 | Python 2 | print '\n'.join(map(str,xrange(1,n+1))) | 1.7621 |
7 | Python 2 | sys.stdout.write('\n'.join(map(str,xrange(1,n+1)))) | 1.7658 |
8 | Python 3 | print('\n'.join(map(str,range(1,n+1)))) | 2.3312 |
9 | Python 3 | sys.stdout.write('\n'.join(map(str,range(1,n+1)))) | 2.337 |
10 | PyPy | sys.stdout.write(''.join(str(i)+'\n' for i in xrange(1,n+1))) | 2.3935 |
11 | PyPy | print ''.join(str(i)+'\n' for i in xrange(1,n+1)) | 2.3974 |
12 | Python 2 | sys.stdout.write(''.join(str(i)+'\n' for i in xrange(1,n+1))) | 2.536 |
13 | Python 2 | print ''.join(str(i)+'\n' for i in xrange(1,n+1)) | 2.5372 |
14 | PyPy3 | for i in range(1,n+1): print(i) | 3.051 |
15 | Python 2 | for i in xrange(1,n+1): print i | 3.069 |
16 | PyPy3 | sys.stdout.write('\n'.join(map(str,range(1,n+1)))) | 3.5625 |
17 | PyPy3 | print('\n'.join(map(str,range(1,n+1)))) | 3.566 |
18 | Python 3 | sys.stdout.write(''.join(str(i)+'\n' for i in range(1,n+1))) | 3.6766 |
19 | Python 3 | print(''.join(str(i)+'\n' for i in range(1,n+1))) | 3.6836 |
20 | PyPy3 | print(''.join(str(i)+'\n' for i in range(1,n+1))) | 3.8326 |
21 | PyPy3 | sys.stdout.write(''.join(str(i)+'\n' for i in range(1,n+1))) | 3.8339 |
22 | Python 2 | for i in xrange(1,n+1): sys.stdout.write(str(i)+'\n') | 4.3475 |
23 | Python 3 | for i in range(1,n+1): sys.stdout.write(str(i)+'\n') | 5.3699 |
24 | Python 3 | for i in range(1,n+1): print(i) | 5.8186 |
25 | PyPy | for i in xrange(1,n+1): os.write(1,str(i)+'\n') | 10.4553 |
26 | PyPy3 | for i in range(1,n+1): os.write(1,(str(i)+'\n').encode('utf-8')) | 12.0509 |
27 | Python 2 | for i in xrange(1,n+1): os.write(1,str(i)+'\n') | 14.8269 |
28 | Python 3 | for i in range(1,n+1): os.write(1,(str(i)+'\n').encode('utf-8')) | 18.2189 |
PyPy 를 사용할 이유가 생기게 만드는 결과표이다