<commit_before>package org.onlab.onos.foo;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.onlab.metrics.MetricsComponent;
import org.onlab.metrics.MetricsFeature;
import org.onlab.metrics.MetricsManager;
import org.onlab.netty.Endpoint;
import org.onlab.netty.NettyMessagingService;
import org.onlab.netty.Response;

import com.codahale.metrics.Timer;

// FIXME: Should be move out to test or app
public final class SimpleNettyClient {
    private SimpleNettyClient() {
    }

    public static void main(String[] args)
            throws IOException, InterruptedException, ExecutionException,
            TimeoutException {
        try {
            startStandalone(args);
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.exit(0);
    }
    public static void startStandalone(String... args) throws Exception {
        NettyMessagingService messaging = new TestNettyMessagingService(9081);
        MetricsManager metrics = new MetricsManager();
        messaging.activate();
        metrics.activate();
        MetricsFeature feature = new MetricsFeature("latency");
        MetricsComponent component = metrics.registerComponent("NettyMessaging");
        Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender");

        final int warmup = 1000000;
        for (int i = 0; i < warmup; i++) {
            messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes());
            Response response = messaging
                    .sendAndReceive(new Endpoint("localhost", 8081), "echo",
                            "Hello World".getBytes());
        }

        final int iterations = 1000000000;
        for (int i = 0; i < iterations; i++) {
            Timer.Context context = sendAsyncTimer.time();
            messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes());
            context.stop();
        }

        Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive");

        for (int i = 0; i < iterations; i++) {
            Timer.Context context = sendAndReceiveTimer.time();
            Response response = messaging
                    .sendAndReceive(new Endpoint("localhost", 8081), "echo",
                                    "Hello World".getBytes());
            // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS)));
            context.stop();
        }
    }

    public static class TestNettyMessagingService extends NettyMessagingService {<commit_msg>Default numbers are more saner now<commit_after>package org.onlab.onos.foo;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.onlab.metrics.MetricsComponent;
import org.onlab.metrics.MetricsFeature;
import org.onlab.metrics.MetricsManager;
import org.onlab.netty.Endpoint;
import org.onlab.netty.NettyMessagingService;
import org.onlab.netty.Response;

import com.codahale.metrics.Timer;

// FIXME: Should be move out to test or app
public final class SimpleNettyClient {
    private SimpleNettyClient() {
    }

    public static void main(String[] args)
            throws IOException, InterruptedException, ExecutionException,
            TimeoutException {
        try {
            startStandalone(args);
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.exit(0);
    }
    public static void startStandalone(String... args) throws Exception {
        NettyMessagingService messaging = new TestNettyMessagingService(9081);
        MetricsManager metrics = new MetricsManager();
        messaging.activate();
        metrics.activate();
        MetricsFeature feature = new MetricsFeature("latency");
        MetricsComponent component = metrics.registerComponent("NettyMessaging");

        final int warmup = 10000;
        for (int i = 0; i < warmup; i++) {
            messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes());
            Response response = messaging
                    .sendAndReceive(new Endpoint("localhost", 8081), "echo",
                            "Hello World".getBytes());
        }

        Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender");
        Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive");

        final int iterations = 10000000;
        for (int i = 0; i < iterations; i++) {
            Timer.Context context = sendAsyncTimer.time();
            messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes());
            context.stop();
        }

        for (int i = 0; i < iterations; i++) {
            Timer.Context context = sendAndReceiveTimer.time();
            Response response = messaging
                    .sendAndReceive(new Endpoint("localhost", 8081), "echo",
                                    "Hello World".getBytes());
            // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS)));
            context.stop();
        }
    }

    public static class TestNettyMessagingService extends NettyMessagingService {
{'fraction_non_alphanumeric': 0.10581811334965166, 'fraction_numerical': 0.015063076633402372, 'mean_word_length': 2.638356164383562, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4939422', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1342, 'n_words': 337}