<commit_before>package com.tinkerpop.gremlin.server;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.IntStream;

/**
 * @author <NAME> (http://stephen.genoprime.com)
 */
public class ProfilingApplication {
    private static final int requests = 100000;
    public static void main (final String[] args) {

        try {

            final long start = System.currentTimeMillis();
            ExecutorService executor = Executors.newFixedThreadPool(8);
            final Future f1 = executor.submit(ProfilingApplication::doWork);
            final Future f2 = executor.submit(ProfilingApplication::doWork);
            final Future f3 = executor.submit(ProfilingApplication::doWork);
            final Future f4 = executor.submit(ProfilingApplication::doWork);
            final Future f5 = executor.submit(ProfilingApplication::doWork);
            final Future f6 = executor.submit(ProfilingApplication::doWork);
            final Future f7 = executor.submit(ProfilingApplication::doWork);
            final Future f8 = executor.submit(ProfilingApplication::doWork);

            f1.get();
            f2.get();
            f3.get();
            f4.get();
            f5.get();
            f6.get();
            f7.get();
            f8.get();

            final long elapsedTimeMs = (System.currentTimeMillis() - start);
            System.out.println("elapsed time (ms): " + elapsedTimeMs);
            System.out.println("request/sec: " + ((requests * 8) / (elapsedTimeMs / 1000)));

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            System.exit(0);
        }
    }

    private static void doWork()  {
        try {
            final String url = "ws://localhost:8182/gremlin";
            final WebSocketClient client = new WebSocketClient(url);
            client.open();
            IntStream.range(0, requests).forEach(i-> {
                try {
                    final int m = i % 100;
                    System.out.println(i + ": " + client.<String>eval("1+" + m).findFirst().orElse("invalid"));
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            });
            client.close();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }

    }
}<commit_msg>Starting a basic benchmarking utility.<commit_after>package com.tinkerpop.gremlin.server;

import com.tinkerpop.gremlin.server.message.RequestMessage;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.util.CharsetUtil;

import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.stream.IntStream;

/**
 * @author <NAME> (http://stephen.genoprime.com)
 */
public class ProfilingApplication {
    public static void main (final String[] args) {

        try {
            final String url = "ws://localhost:8182/gremlin";
            new Worker(20, 100, new URI(url)).execute();


        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            System.exit(0);
        }
    }

    public static class Worker {
        private final int numberOfConnections;
        private final int numberOfMessages;
        private final URI uri;

        public Worker(final int numberOfConnections, final int numberOfMessages,
                      final URI uri) {
            this.numberOfConnections = numberOfConnections;
            this.numberOfMessages = numberOfMessages;
            this.uri = uri;
        }

        public void execute() throws Exception {
            final EventLoopGroup group = new NioEventLoopGroup();

            final CountDownLatch complete = new CountDownLatch(numberOfConnections);

            for (int ix = 0; ix < numberOfConnections; ix++) {
                final Bootstrap b = new Bootstrap();
                final String protocol = uri.getScheme();
                if (!"ws".equals(protocol)) {
                    throw new IllegalArgumentException("Unsupported protocol: " + protocol);
                }

                final WebSocketClientHandler handler =
                        new WebSocketClientHandler(
                                WebSocketClientHandshakerFactory.newHandshaker(
                                        uri, WebSocketVersion.V13, null, false, HttpHeaders.EMPTY_HEADERS, 1280000));

                b.group(group)
                    .channel(NioSocketChannel.class)
                    .handler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        public void initChannel(SocketChannel ch) throws Exception {
                            final ChannelPipeline pipeline = ch.pipeline();
                            pipeline.addLast("http-codec", new HttpClientCodec());
                            pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
                            pipeline.addLast("ws-handler", handler);
                        }
                    });

                final Channel ch = b.connect(uri.getHost(), uri.getPort()).sync().channel();
                handler.handshakeFuture().addListener(future -> {
                    IntStream.range(0, numberOfMessages).forEach(i -> {
                        final RequestMessage msg = RequestMessage.create(Tokens.OPS_EVAL).add(
                                Tokens.ARGS_GREMLIN, "1+1", Tokens.ARGS_ACCEPT, "application/json").build();
                        ch.writeAndFlush(new TextWebSocketFrame("application/json|-" + MessageSerializer.DEFAULT_REQUEST_SERIALIZER.serialize(msg)));
                    });

                    complete.countDown();
                });
            }

            complete.await();
        }
    }

    public static class WebSocketClientHandler extends SimpleChannelInboundHandler<Object> {
        private final WebSocketClientHandshaker handshaker;
        private ChannelPromise handshakeFuture;

        public WebSocketClientHandler(final WebSocketClientHandshaker handshaker) {
            this.handshaker = handshaker;
        }

        public ChannelFuture handshakeFuture() {
            return handshakeFuture;
        }

        @Override
        public void handlerAdded(final ChannelHandlerContext ctx) throws Exception {
            handshakeFuture = ctx.newPromise();
        }

        @Override
        public void channelActive(final ChannelHandlerContext ctx) throws Exception {
            handshaker.handshake(ctx.channel());
        }

        @Override
        public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
            //System.out.println("WebSocket Client disconnected!");
        }

        @Override
        protected void channelRead0(final ChannelHandlerContext ctx, final Object msg) throws Exception {
            final Channel ch = ctx.channel();
            if (!handshaker.isHandshakeComplete()) {
                // web socket client connected
                handshaker.finishHandshake(ch, (FullHttpResponse) msg);
                handshakeFuture.setSuccess();
                return;
            }

            if (msg instanceof FullHttpResponse) {
                final FullHttpResponse response = (FullHttpResponse) msg;
                throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", content="
                        + response.content().toString(CharsetUtil.UTF_8) + ')');
            }

            final WebSocketFrame frame = (WebSocketFrame) msg;
            if (frame instanceof TextWebSocketFrame) {
                final TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
                System.out.println(textFrame.text());
            } else if (frame instanceof PongWebSocketFrame) {
            } else if (frame instanceof BinaryWebSocketFrame) {
            } else if (frame instanceof CloseWebSocketFrame)
                ch.close();

        }

        @Override
        public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
            cause.printStackTrace();

            if (!handshakeFuture.isDone()) {
                handshakeFuture.setFailure(cause);
            }

            ctx.close();
        }
    }
}
{'fraction_non_alphanumeric': 0.09566673644546787, 'fraction_numerical': 0.0071174377224199285, 'mean_word_length': 2.180758988015979, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '6038264', 'n_tokens_mistral': 2513, 'n_tokens_neox': 2373, 'n_words': 499}