<commit_before>/*
 * Copyright 2012 <NAME>
 * 
 * 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 org.pmw.benchmark;

import java.io.File;
import java.text.MessageFormat;

public abstract class AbstractBenchmarkRunner {

	private static final int BENCHMARK_ITERATIONS = 100;
	private static final String RESULT_MESSAGE = "{0}: {1} log entries in {2}ms = {3} log entries per second";

	private final String name;
	private final IBenchmark benchmark;

	AbstractBenchmarkRunner(final String name, final IBenchmark benchmark) {
		this.name = name;
		this.benchmark = benchmark;
	}

	public final void start() throws Exception {
		long start = System.currentTimeMillis();

		for (int i = 0; i < BENCHMARK_ITERATIONS; ++i) {
			File file = File.createTempFile("log", ".txt");
			benchmark.init(file);
			run(benchmark);
			benchmark.dispose();
			file.delete();
		}

		long finished = System.currentTimeMillis();
		long time = finished - start;
		long iterations = BENCHMARK_ITERATIONS * countLogEntries();
		long iterationsPerSecond = Math.round(iterations * 1000d / time);
		System.out.println(MessageFormat.format(RESULT_MESSAGE, name, iterations, time, iterationsPerSecond));
	}

	protected abstract int countLogEntries();

	protected abstract void run(IBenchmark benchmark);

}<commit_msg>Do not count creation and deleting of temp files in benchmark<commit_after>/*
 * Copyright 2012 <NAME>
 * 
 * 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 org.pmw.benchmark;

import java.io.File;
import java.text.MessageFormat;

public abstract class AbstractBenchmarkRunner {

	private static final int BENCHMARK_ITERATIONS = 100;
	private static final String RESULT_MESSAGE = "{0}: {1} log entries in {2}ms = {3} log entries per second";

	private final String name;
	private final IBenchmark benchmark;

	AbstractBenchmarkRunner(final String name, final IBenchmark benchmark) {
		this.name = name;
		this.benchmark = benchmark;
	}

	public final void start() throws Exception {
		File[] files = new File[BENCHMARK_ITERATIONS];
		for (int i = 0; i < BENCHMARK_ITERATIONS; ++i) {
			File file = File.createTempFile("log", ".txt");
			file.deleteOnExit();
			files[i] = file;
		}

		long start = System.currentTimeMillis();

		for (int i = 0; i < BENCHMARK_ITERATIONS; ++i) {
			benchmark.init(files[i]);
			run(benchmark);
			benchmark.dispose();
		}

		long finished = System.currentTimeMillis();
		long time = finished - start;
		long iterations = BENCHMARK_ITERATIONS * countLogEntries();
		long iterationsPerSecond = Math.round(iterations * 1000d / time);

		for (int i = 0; i < BENCHMARK_ITERATIONS; ++i) {
			files[i].delete();
		}

		System.out.println(MessageFormat.format(RESULT_MESSAGE, name, iterations, time, iterationsPerSecond));
	}

	protected abstract int countLogEntries();

	protected abstract void run(IBenchmark benchmark);

}
{'fraction_non_alphanumeric': 0.09610389610389611, 'fraction_numerical': 0.01090909090909091, 'mean_word_length': 4.378491620111732, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6539166', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1081, 'n_words': 403}