<commit_before>package com.emcaster.topics;

import java.io.IOException;
import java.util.Iterator;
import java.util.regex.Pattern;

import com.emcaster.topics.Message;
import com.emcaster.topics.UdpPublisher;
import com.emcaster.topics.UdpSubscriber;

public class Main {

	public static void main(String[] args) throws Exception {
		String address = "172.16.31.10";
		int port = 8001;
		// receive(address, port);
		send(address, port);
	}

	private static void send(String address, int port) throws 
			InterruptedException {
		UdpPublisher pub = new UdpPublisher(address, port);
		pub.connect();
		BatchWriter writer = new BatchWriter(1024*25, pub, pub.getAddress(), pub.getPort());
		Thread thread = new Thread(writer);
		thread.start();
		int count = 0;
		long startTime = System.currentTimeMillis();
		while (true) {
			count++;
			String msg = "msg: " + count;
			byte[] bytes = msg.getBytes();
			writer.publish("test", bytes, 0, bytes.length);
			if ((count % 50000) == 0) {
				long totalTime = System.currentTimeMillis() - startTime;
				System.out.println("count: " + count);
				double avg = count / (totalTime / 1000.00);
				System.out.println("avg/sec: " + avg);
				count = 0;
				startTime = System.currentTimeMillis();
			}
		}
	}

	private static void receive(String address, int port) throws IOException {
		UdpSubscriber sub = new UdpSubscriber(address, port,
				64 * 1024);<commit_msg>optimize<commit_after>package com.emcaster.topics;

import java.io.IOException;
import java.util.Iterator;
import java.util.regex.Pattern;

import com.emcaster.topics.Message;
import com.emcaster.topics.UdpPublisher;
import com.emcaster.topics.UdpSubscriber;

public class Main {

	public static void main(String[] args) throws Exception {
		String address = "172.16.31.10";
		int port = 8001;
		//receivePattern(address, port);
		receive(address, port);
		//send(address, port);
	}

	private static void send(String address, int port) throws 
			InterruptedException {
		UdpPublisher pub = new UdpPublisher(address, port);
		pub.connect();
		BatchWriter writer = new BatchWriter(1024*25, pub, pub.getAddress(), pub.getPort());
		writer.setAfterFlushSleep(0);
		Thread thread = new Thread(writer);
		thread.start();
		int count = 0;
		long startTime = System.currentTimeMillis();
		byte[] bytes = new byte[0];
		while (true) {
			count++;
			writer.publish("test", bytes, 0, bytes.length);
			if ((count % 500000) == 0) {
				long totalTime = System.currentTimeMillis() - startTime;
				System.out.println("count: " + count);
				double avg = count / (totalTime / 1000.00);
				System.out.println("avg/sec: " + avg);
				count = 0;
				startTime = System.currentTimeMillis();
			}
		}
	}

	private static void receive(String address, int port) throws IOException {
		UdpSubscriber sub = new UdpSubscriber(address, port,
				64 * 1024);
{'fraction_non_alphanumeric': 0.13181019332161686, 'fraction_numerical': 0.029173989455184533, 'mean_word_length': 4.001757469244288, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6193361', 'n_tokens_mistral': 1089, 'n_tokens_neox': 909, 'n_words': 235}