<commit_before>/*
 * Copyright 2014 Higher Frequency Trading
 *
 * http://www.higherfrequencytrading.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.openhft.chronicle.map.example;

import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;

import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;

/**
 * Created by peter on 12/11/14.
 */
public class ServersMapMain {
    static final int port = Integer.getInteger("port", 8989);
    static final int entries = Integer.getInteger("entries", 10000);
    static final int runs = Integer.getInteger("runs", 5);

    public static void startServer() throws IOException {
        File file = File.createTempFile("testServersMapMain", ".deleteme");
        file.deleteOnExit();
        final ChronicleMap<byte[], byte[]> serverMap = ChronicleMapBuilder.of(byte[].class, byte[].class)
                .putReturnsNull(true)
                .entrySize(50)
                .replication((byte) 2, TcpTransportAndNetworkConfig.of(port))
                .createPersistedTo(file);
        System.out.println("Server started");
        System.in.read();
        serverMap.close();
    }

    public static void startRemoteClient(String hostname) throws IOException {
        final ChronicleMap<byte[], byte[]> map = ChronicleMapBuilder.of(
                byte[].class, byte[].class)
                .putReturnsNull(true)
                .statelessClient(new InetSocketAddress(hostname, port)).create();
        ByteBuffer key = ByteBuffer.allocate(8);
        ByteBuffer value = ByteBuffer.allocate(32);
        double lastAveragePut = Double.POSITIVE_INFINITY, lastAverageGet = Double.POSITIVE_INFINITY;
        for (int i = 0; i < runs; i++) {
            long puts = 0, gets = 0;
            for (int j = 0; j < entries; j++) {
                key.putLong(0, j);<commit_msg>Ensure Nagle is always off.<commit_after>/*
 * Copyright 2014 Higher Frequency Trading
 *
 * http://www.higherfrequencytrading.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.openhft.chronicle.map.example;

import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;

import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;

/**
 * Created by peter on 12/11/14.
 */
public class ServersMapMain {
    static final int port = Integer.getInteger("port", 8989);
    static final int entries = Integer.getInteger("entries", 100000);
    static final int runs = Integer.getInteger("runs", 5);

    public static void startServer() throws IOException {
        File file = File.createTempFile("testServersMapMain", ".deleteme");
        file.deleteOnExit();
        final ChronicleMap<byte[], byte[]> serverMap = ChronicleMapBuilder.of(byte[].class, byte[].class)
                .putReturnsNull(true)
                .entrySize(50)
                .replication((byte) 2, TcpTransportAndNetworkConfig.of(port))
                .createPersistedTo(file);
        System.out.println("Server started");
        System.in.read();
        serverMap.close();
    }

    public static void startRemoteClient(String hostname) throws IOException {
        final ChronicleMap<byte[], byte[]> map = ChronicleMapBuilder.of(
                byte[].class, byte[].class)
                .putReturnsNull(true)
                .statelessClient(new InetSocketAddress(hostname, port)).create();
        ByteBuffer key = ByteBuffer.allocate(8);
        ByteBuffer value = ByteBuffer.allocate(32);
        double lastAveragePut = Double.POSITIVE_INFINITY, lastAverageGet = Double.POSITIVE_INFINITY;
        for (int i = 0; i < runs; i++) {
            long puts = 0, gets = 0;
            for (int j = 0; j < entries; j++) {
                key.putLong(0, j);
{'fraction_non_alphanumeric': 0.10604558969276512, 'fraction_numerical': 0.014073339940535183, 'mean_word_length': 3.1158238172920063, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4824309', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1377, 'n_words': 411}