Hirdetés
- ubyegon2: Airfryer XL XXL forrólevegős sütő gyakorlati tanácsok, ötletek, receptek
- Pajac: Hawking
- Meggyi001: Áram nélkül....méltóság nélkül.....
- Sapphi: StremHU | Source – Self-hostolható Stremio addon magyar trackerekhez
- sziku69: Szólánc.
- sziku69: Fűzzük össze a szavakat :)
- Luck Dragon: MárkaLánc
- MasterDeeJay: Intel Optane M10: mire lehet használni?
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- Lalikiraly: Commodore The C64, Ultimate
Új hozzászólás Aktív témák
-
disy68
aktív tag
válasz
#74220800
#9284
üzenetére
Java 8 alatt van lehetőség metódus referenciát átadni. Akár az alábbihoz hasonlóan is elindulhatsz:
public class MethodRuntimeChecker {
public static void main(String[] args) {
QuickSorter sorter = new QuickSorter();
int[] array = getNumbers(10_000);
System.out.println(mesureRunTimeNano(sorter::sort, array) + " ns");
System.out.println(mesureRunTimeMilli(sorter::sort, array) + " ms");
}
public static long mesureRunTimeNano(Function<int[], int[]> intSorter, int[] toBeSorted) {
long start = System.nanoTime();
intSorter.apply(toBeSorted);
return System.nanoTime() - start;
}
public static long mesureRunTimeMilli(Function<int[], int[]> intSorter, int[] toBeSorted) {
long start = System.currentTimeMillis();
intSorter.apply(toBeSorted);
return System.currentTimeMillis() - start;
}
private static int[] getNumbers(int count) {
int[] numbers = new int[count];
Random random = new Random();
for (int i = 0; i < count; i++) {
numbers[i] = random.nextInt(count);
}
return numbers;
}
}
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- Poco X8 Pro Max - nem kell ide sem bank, sem akkubank
- A fociról könnyedén, egy baráti társaságban
- Mikrotik routerek
- PlayStation 5
- AMD vs. INTEL vs. NVIDIA
- Gumi és felni topik
- Mozilla Firefox
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- Épített vízhűtés (nem kompakt) topic
- Samsung Galaxy Felhasználók OFF topicja
- További aktív témák...
- Mini Pc HP ProDesk 600 G2 / G4 / G5 // 6-9. gen // i3 / i5
- GAMING PC! i5-12400F / RTX 5060 / 32GB DDR5 / 512GB NVMe / 600w! BeszámítOK
- GYÖNYÖRŰ iPhone 15 Pro 128GB Blue Titanium -1 ÉV GARANCIA - Kártyafüggetlen, MS4680
- Apple iPhone 16 Pro Max 256GB Black Titanium használt, szép állapot 96% akku (247 ciklus) 6 hó
- Telefon felvásárlás!! Samsung Galaxy A12/Samsung Galaxy A22/Samsung Galaxy A32/Samsung Galaxy A52
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
