Coding Test/BaekJoon

[백준] 입력 속도 비교

owls 2023. 5. 10. 12:26
728x90

백준에 올라와 있는 입력 속도 비교 글을 기억하기 위해 제 블로그에 옮겨 왔습니다.

 

출처는 아래 링크를 참고해주세요.

 

정수의 개수 N(=10,000,000), 둘째 줄부터 N개의 줄에 한 개의 자연수(10,000 이하)가 적힌 파일을 입력받는데 걸리는 시간을 측정. 10번 측정하여 평균값으로 순위를 매겼다고 합니다.

 

순위 언어 입력 방법 평균(초)
1 C11 mmap 0.043
2 C11 fread 0.0799
3 C11 getchar 0.3496
4 C++17 ios_base::sync_with_stdio(false); cin.tie(NULL); 0.5938
5 C++17 ios_base::sync_with_stdio(false); 0.6348
6 Java BufferedReader, Integer.parseInt 0.6585
7 C11 scanf 0.9206
8 PyPy int(sys.stdin.readline()) 0.9229
9 PyPy map(int, os.read(0, 100000000).split('\n')) 1.1169
10 PyPy3 map(int, os.read(0, 100000000).decode('utf-8').split('\n')) 1.5408
11 PyPy int(raw_input()) 1.925
12 C++17 cin.tie(NULL); 2.059
13 C++17 cin 2.1742
14 C# 6.0 int.Parse(Console.ReadLine()) 2.9635
15 Python3 map(int, os.read(0, os.read(0, 100000000).decode('utf-8').split('\n')) 4.4033
16 Python3 int(sys.stdin.readline()) 4.4394
17 Java Scanner 4.8448
18 Python2 map(int, os.read(0, 100000000).split('\n')) 4.8553
19 Python2 int(sys.stdin.readline()) 5.7471
20 PyPy3 int(sys.stdin.readline()) 6.6291
21 Python2 int(raw_input()) 8.9765
22 Python3 int(input()) 12.4443
23 PyPy3 int(input()) 17.3772
24 Python2 input() 37.7823
25 PyPy input() 110.3676

 

 

블로그 - 전체 글

여러가지 언어와 입력 방법을 이용해서 시간이 얼마나 걸리는지 비교해 보았습니다. 방법: 첫째 줄에 정수의 개수 N (= 10,000,000), 둘째 줄부터 N개의 줄에 한 개의 자연수(10,000 이하)가 적힌 파일

www.acmicpc.net

 

728x90