<commit_before>package com.treetank.xmlprague;

import java.io.File;
import java.util.Properties;

import com.treetank.TestHelper;
import com.treetank.TestHelper.PATHS;
import com.treetank.access.Database;
import com.treetank.access.WriteTransaction;
import com.treetank.api.IDatabase;
import com.treetank.api.ISession;
import com.treetank.api.IWriteTransaction;
import com.treetank.exception.TTException;
import com.treetank.service.xml.shredder.EShredderInsert;
import com.treetank.service.xml.shredder.XMLShredder;

import org.perfidix.Benchmark;
import org.perfidix.annotation.AfterEachRun;
import org.perfidix.annotation.Bench;
import org.perfidix.ouput.CSVOutput;
import org.perfidix.ouput.TabularSummaryOutput;
import org.perfidix.result.BenchmarkResult;

public class ShredBench {

    private XMLShredder shredderNone;

    private static final int RUNS = 100;

    public static File XMLFile = new File("src" + File.separator + "main" + File.separator + "resources"
        + File.separator + "small.xml");
    public static File TNKFolder = new File("tnk");

    private int counter=0;
    
    public void beforeFirst(){
        final Properties props = new Properties();
        props.put("", "");
    }
    
    public void beforeShred() {
        try {
            System.out.println("Starting Shredding " + counter);
            final IDatabase database = Database.openDatabase(new File(TNKFolder, XMLFile.getName() + ".tnk"));
            final ISession session = database.getSession();
            final IWriteTransaction wtx = session.beginWriteTransaction();
            if (wtx.moveToFirstChild()) {
                wtx.remove();
            }
            shredderNone =
                new XMLShredder(wtx, XMLShredder.createReader(XMLFile), EShredderInsert.ADDASFIRSTCHILD);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Bench(beforeEachRun = "beforeShred", afterEachRun = "tearDown", runs = RUNS)
    public void benchInsert() {
        try {
            shredderNone.call();
        } catch (TTException e) {
            e.printStackTrace();
        }
    }

    public void tearDown() {
        try {
            System.out.println("Finished Shredding Version " + counter);
            Database.forceCloseDatabase(new File(TNKFolder, XMLFile.getName() + ".tnk"));
        } catch (TTException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static void main(final String[] args) {

        if (args.length != 2) {
            System.out
                .println("Please use java -jar JAR \"folder with xmls to parse\" \"folder to write csv\"");
            System.exit(-1);<commit_msg>counter adaption<commit_after>package com.treetank.xmlprague;

import java.io.File;
import java.util.Properties;

import com.treetank.TestHelper;
import com.treetank.TestHelper.PATHS;
import com.treetank.access.Database;
import com.treetank.access.WriteTransaction;
import com.treetank.api.IDatabase;
import com.treetank.api.ISession;
import com.treetank.api.IWriteTransaction;
import com.treetank.exception.TTException;
import com.treetank.service.xml.shredder.EShredderInsert;
import com.treetank.service.xml.shredder.XMLShredder;

import org.perfidix.Benchmark;
import org.perfidix.annotation.AfterEachRun;
import org.perfidix.annotation.Bench;
import org.perfidix.ouput.CSVOutput;
import org.perfidix.ouput.TabularSummaryOutput;
import org.perfidix.result.BenchmarkResult;

public class ShredBench {

    private XMLShredder shredderNone;

    private static final int RUNS = 100;

    public static File XMLFile = new File("src" + File.separator + "main" + File.separator + "resources"
        + File.separator + "small.xml");
    public static File TNKFolder = new File("tnk");

    private int counter=0;
    
    public void beforeFirst(){
        final Properties props = new Properties();
        props.put("", "");
    }
    
    public void beforeShred() {
        try {
            System.out.println("Starting Shredding " + counter);
            final IDatabase database = Database.openDatabase(new File(TNKFolder, XMLFile.getName() + ".tnk"));
            final ISession session = database.getSession();
            final IWriteTransaction wtx = session.beginWriteTransaction();
            if (wtx.moveToFirstChild()) {
                wtx.remove();
            }
            shredderNone =
                new XMLShredder(wtx, XMLShredder.createReader(XMLFile), EShredderInsert.ADDASFIRSTCHILD);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Bench(beforeEachRun = "beforeShred", afterEachRun = "tearDown", runs = RUNS)
    public void benchInsert() {
        try {
            shredderNone.call();
        } catch (TTException e) {
            e.printStackTrace();
        }
    }

    public void tearDown() {
        try {
            System.out.println("Finished Shredding Version " + counter);
            counter++;
            Database.forceCloseDatabase(new File(TNKFolder, XMLFile.getName() + ".tnk"));
        } catch (TTException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static void main(final String[] args) {

        if (args.length != 2) {
            System.out
                .println("Please use java -jar JAR \"folder with xmls to parse\" \"folder to write csv\"");
            System.exit(-1);
{'fraction_non_alphanumeric': 0.1097069597069597, 'fraction_numerical': 0.002197802197802198, 'mean_word_length': 2.6382411725516324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '6274540', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1586, 'n_words': 349}