<commit_before>package main

import (
	"flag"
	"fmt"
	"os"
)

// global command line parameters
var runs *int
var cpus [2]string
var threads *string
var hermitcore *bool

var resctrlPath *string
var cat *bool
var catBitChunk *uint64
var catDirs []string

var varianceDiff *float64

func parseArgs() *string {
	runs = flag.Int("runs", 2, "Number of times the applications are executed")
	commandFile := flag.String("cmd", "cmd.txt", "Text file containing the commands to execute")

	cpus0 := flag.String("cpus0", "0-4", "List of CPUs to be used for the 1st command")
	cpus1 := flag.String("cpus1", "5-9", "List of CPUs to be used for the 2nd command")
	threads = flag.String("threads", "5", "Number of threads to be used")

	cat = flag.Bool("cat", false, "Measure with all CAT settings")
	catBitChunk = flag.Uint64("catChunk", 2, "Bits changed from one run to the next")
	resctrlPath = flag.String("resctrl", "/sys/fs/resctrl/", "Root path of the resctrl file system")

	hermitcore = flag.Bool("hermitcore", false, "Use if you are executing hermitcore binaries")

	varianceDiff = flag.Float64("variance", 0.001, "Minimum differences in variance required between runs")

	flag.Parse()
	catDirs = []string{*resctrlPath + "/cobench0", *resctrlPath + "/cobench1"}

	if *runs < 1 {
		fmt.Println("runs must be > 0")
		os.Exit(0)
	}
	if *catBitChunk < 1 {
		fmt.Println("catChunk must be > 0")
		os.Exit(0)
	}

	cpus[0] = *cpus0
	cpus[1] = *cpus1

	return commandFile
}

func storeConfig(commands []string) error {
	file, err := os.Create("coBench.config")
	if err != nil {
		return fmt.Errorf("Error while creating file: %v", err)
	}

	out := fmt.Sprintf("Runs: %v \n", *runs)
	out += fmt.Sprintf("CPUs: %v \n", cpus)
	out += fmt.Sprintf("Threads: %v \n", *threads)
	out += fmt.Sprintf("HermitCore: %v \n", *hermitcore)
	out += fmt.Sprintf("CAT: %v \n", *cat)
	out += fmt.Sprintf("CAT chunk: %v \n", *catBitChunk)
	out += fmt.Sprintf("CAT dirs: %v \n", catDirs)
	out += fmt.Sprintf("resctrlPath: %v \n", *resctrlPath)
	out += fmt.Sprintf("Variance diff: %v \n", *varianceDiff)
	out += fmt.Sprintf("Commands: %v \n", commands)

	_, err = file.WriteString(out)
	if err != nil {
		return err<commit_msg>Restructoring.<commit_after>package main

import (
	"flag"
	"fmt"
	"os"
)

// global command line parameters
var runs *int
var cpus [2]string
var threads *string
var hermitcore *bool

var resctrlPath *string
var cat *bool
var catBitChunk *uint64
var catDirs []string

var varianceDiff *float64

func parseArgs() *string {
	runs = flag.Int("runs", 2, "Number of times the applications are executed")
	commandFile := flag.String("cmd", "cmd.txt", "Text file containing the commands to execute")

	cpus0 := flag.String("cpus0", "0-4", "List of CPUs to be used for the 1st command")
	cpus1 := flag.String("cpus1", "5-9", "List of CPUs to be used for the 2nd command")
	threads = flag.String("threads", "5", "Number of threads to be used")

	cat = flag.Bool("cat", false, "Measure with all CAT settings")
	catBitChunk = flag.Uint64("catChunk", 2, "Bits changed from one run to the next")
	resctrlPath = flag.String("resctrl", "/sys/fs/resctrl/", "Root path of the resctrl file system")

	hermitcore = flag.Bool("hermitcore", false, "Use if you are executing hermitcore binaries")

	varianceDiff = flag.Float64("variance", 0.001, "Minimum differences in variance required between runs")

	flag.Parse()
	catDirs = []string{*resctrlPath + "/cobench0", *resctrlPath + "/cobench1"}

	if *runs < 1 {
		fmt.Println("runs must be > 0")
		os.Exit(0)
	}
	if *catBitChunk < 1 {
		fmt.Println("catChunk must be > 0")
		os.Exit(0)
	}

	cpus[0] = *cpus0
	cpus[1] = *cpus1

	return commandFile
}

func storeConfig(commands []string) error {
	file, err := os.Create("coBench.config")
	if err != nil {
		return fmt.Errorf("Error while creating file: %v", err)
	}

	out := fmt.Sprintf("Runs: %v \n", *runs)
	out += fmt.Sprintf("Variance diff: %v \n", *varianceDiff)

	out += fmt.Sprintf("CPUs: %v \n", cpus)
	out += fmt.Sprintf("Threads: %v \n", *threads)

	out += fmt.Sprintf("HermitCore: %v \n", *hermitcore)

	out += fmt.Sprintf("CAT: %v \n", *cat)
	out += fmt.Sprintf("CAT chunk: %v \n", *catBitChunk)
	out += fmt.Sprintf("CAT dirs: %v \n", catDirs)
	out += fmt.Sprintf("resctrlPath: %v \n", *resctrlPath)

	out += fmt.Sprintf("Commands: %v \n", commands)

	_, err = file.WriteString(out)
	if err != nil {
		return err
{'fraction_non_alphanumeric': 0.1613931254268154, 'fraction_numerical': 0.017300250398361028, 'mean_word_length': 4.306763285024155, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2152745', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1586, 'n_words': 497}