MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / main

Method main

test/test/proc/IoIntensiveApp.java:22–56  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

20 private static final int BLOCK = 64 * 1024 * 1024;
21
22 public static void main(String[] args) throws Exception {
23 Path tmp = Files.createTempFile("proc-test", ".tmp");
24
25 // burn some cpu to pass the min cpu % threshold
26 new Thread(() -> {
27 while (true) {
28 long n = random.nextLong();
29 if (Long.toString(n).hashCode() == 0) {
30 System.out.println(n);
31 }
32 }
33 }).start();
34
35 // write
36 byte[] payload = new byte[BLOCK];
37 random.nextBytes(payload);
38
39 try (FileChannel ch = FileChannel.open(tmp, StandardOpenOption.CREATE, StandardOpenOption.WRITE,
40 StandardOpenOption.DSYNC)) {
41 ByteBuffer buf = ByteBuffer.wrap(payload);
42 while (buf.hasRemaining()) {
43 ch.write(buf);
44 }
45
46 ch.force(true);
47 }
48
49 // read
50 try (FileChannel f = FileChannel.open(tmp, StandardOpenOption.READ)) {
51 ByteBuffer b = ByteBuffer.allocate(BLOCK);
52 f.read(b);
53 }
54
55 Thread.sleep(20000);
56 }
57}

Callers

nothing calls this directly

Calls 8

createTempFileMethod · 0.80
openMethod · 0.80
startMethod · 0.65
hashCodeMethod · 0.45
toStringMethod · 0.45
writeMethod · 0.45
allocateMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected