728x90 반응형 시간측정2 시간 측정 테스트시 주의할 점 public static void main(String[] args) { // Test data int n = 100000; // Example value for n int[] sArray = {200, 400, 800}; // Example array of station locations int w = 100; // Example value for w // Measure time for the first solution long startTime1 = System.nanoTime(); int result1 = solution1(n, sArray, w); long endTime1 = System.nanoT.. 2024. 9. 2. 비트연산 과연 더 빠른가? 비트연산이란? "한 개 혹은 두 개의 이진수에 대해 비트 단위로 적용되는 연산이다." - 위키백과- 비트연산을 사용하는 이유? 컴퓨터가 자료형(int, long double 등등)을 비트로 변환하는 작업을 사용자가 미리 해주기 때문에 빠름 대표적으로 > = /이 있음 정말로 비트연산이 기본 연산보다 빠른가? 여러 언어들마다 실행시간을 측정할 수 있습니다. java 곱하기 + 나누기 long beforeTime = System.currentTimeMillis(); long n = 1, m = 1; for(int i = 0; i < 1000000; i++) { for(int j = 0; j < 5000; j++) { n *= 2; m *= 2; n /= 2; m /= 2; } } long afterTime .. 2023. 2. 28. 이전 1 다음 728x90 반응형