Home / Function/ run() — netty Function Reference

run() — netty Function Reference

Architecture documentation for the run() function in AllocationPatternSimulator.java from the netty codebase.

Function java Buffer Telemetry calls 3 called by 2

Entity Profile

Dependency Diagram

graph TD
  76ec3af2_8878_9d60_39b7_18461aa6fefd["run()"]
  4ed8382e_6455_1b00_c128_dbdce6457ea2["AllocationPatternSimulator"]
  76ec3af2_8878_9d60_39b7_18461aa6fefd -->|defined in| 4ed8382e_6455_1b00_c128_dbdce6457ea2
  06934b47_b83d_1faa_16c1_8d69d2ca2fd8["run()"]
  06934b47_b83d_1faa_16c1_8d69d2ca2fd8 -->|calls| 76ec3af2_8878_9d60_39b7_18461aa6fefd
  eed6d081_2fa9_2b93_44a4_f9f70f42baae["main()"]
  eed6d081_2fa9_2b93_44a4_f9f70f42baae -->|calls| 76ec3af2_8878_9d60_39b7_18461aa6fefd
  06934b47_b83d_1faa_16c1_8d69d2ca2fd8["run()"]
  76ec3af2_8878_9d60_39b7_18461aa6fefd -->|calls| 06934b47_b83d_1faa_16c1_8d69d2ca2fd8
  99f6cde3_0ee5_22d5_f91f_0a12e1561207["AllocConfig()"]
  76ec3af2_8878_9d60_39b7_18461aa6fefd -->|calls| 99f6cde3_0ee5_22d5_f91f_0a12e1561207
  bf2c887c_0e83_62ec_db0a_3fd73c2c9951["usedMemory()"]
  76ec3af2_8878_9d60_39b7_18461aa6fefd -->|calls| bf2c887c_0e83_62ec_db0a_3fd73c2c9951
  style 76ec3af2_8878_9d60_39b7_18461aa6fefd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

microbench/src/main/java/io/netty/buffer/AllocationPatternSimulator.java lines 500–575

    void run(int concurrencyLevel, int runningTimeSeconds) throws Exception {
        AllocConfig[] allocs = {
                new AllocConfig(true, 128),
                new AllocConfig(false, 128),
                new AllocConfig(true, 512),
                new AllocConfig(false, 512),
                new AllocConfig(true, 1024),
                new AllocConfig(false, 1024),
        };

        CountDownLatch startLatch = new CountDownLatch(1);
        AtomicBoolean stopCondition = new AtomicBoolean();
        List<Thread> threads = new ArrayList<>();

        for (int i = 0; i < concurrencyLevel; i++) {
            for (AllocConfig alloc : allocs) {
                threads.add(alloc.start(startLatch, stopCondition));
            }
        }

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        JFreeChart chart = ChartFactory.createLineChart("Memory Usage", "Time", "Bytes", dataset);
        for (int i = 0; i < allocs.length; i++) {
            chart.getCategoryPlot().getRenderer().setSeriesStroke(i, new BasicStroke(3.0f));
        }
        int windowWidth = 1400;
        int windowHeight = 1050;
        ImageIcon image = new ImageIcon(chart.createBufferedImage(windowWidth, windowHeight - 30));

        JFrame frame = new JFrame("Results");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(new JLabel(image));
        frame.setBounds(0, 0, windowWidth, windowHeight);
        frame.setVisible(true);
        Runnable updateImage = () -> {
            Rectangle bounds = frame.getBounds();
            image.setImage(chart.createBufferedImage(bounds.width, bounds.height - 30));
            frame.repaint();
        };
        frame.addComponentListener(new ComponentAdapter() {
            @Override
            public void componentResized(ComponentEvent e) {
                updateImage.run();
            }
        });

        startLatch.countDown();

        System.out.println("Time," + Stream.of(allocs)
                .map(AllocConfig::name)
                .collect(Collectors.joining("\",\"", "\"", "\"")));
        for (int i = 0; i < runningTimeSeconds; i++) {
            Thread.sleep(1000);
            Integer iteration = Integer.valueOf(i);

            long[] usages = new long[allocs.length];
            for (int j = 0; j < usages.length; j++) {
                usages[j] = allocs[j].usedMemory();
            }
            System.out.println(iteration + "," + LongStream.of(usages)
                    .mapToObj(String::valueOf).collect(Collectors.joining(",")));
            SwingUtilities.invokeLater(() -> {
                for (int j = 0; j < usages.length; j++) {
                    dataset.addValue(usages[j], allocs[j].name(), iteration);
                }
                updateImage.run();
            });
        }

        stopCondition.set(true);

        for (Thread thread : threads) {
            thread.join();
        }
        System.out.println("\nDone");
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does run() do?
run() is a function in the netty codebase, defined in microbench/src/main/java/io/netty/buffer/AllocationPatternSimulator.java.
Where is run() defined?
run() is defined in microbench/src/main/java/io/netty/buffer/AllocationPatternSimulator.java at line 500.
What does run() call?
run() calls 3 function(s): AllocConfig, run, usedMemory.
What calls run()?
run() is called by 2 function(s): main, run.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free