Skip to content

Commit

Permalink
update scripts for producing latex tables
Browse files Browse the repository at this point in the history
  • Loading branch information
franktip committed Dec 26, 2024
1 parent c0c525f commit 674c845
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 179 deletions.
20 changes: 17 additions & 3 deletions benchmark/compareTemperatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,28 @@ function generateTable(baseDir: string, runs: string[]): void {
// \caption{the table}
// \end{table*}

const runNrs = runs.map((path) => path.substring(path.lastIndexOf("run"), path.length).replace("run", "run \\#"));
const runNrs = runs.map((path) =>
path
.substring(path.lastIndexOf("run"), path.length)
.replace("run", "run \\#")
);
let latexTable = `
% This table was generated using command: "node benchmark/compareTemperatures.js ${baseDir} ${runs.join(" ")}
% This table was generated using command: "node benchmark/compareTemperatures.js ${baseDir} ${runs.join(
" "
)}
\\begin{table*}
\\centering
{\\scriptsize
\\begin{tabular}{l||rrrr|rrrr|rrrr|rrrr}
& \\multicolumn{4}{|c|}{\\bf temp. 0.0 \\ChangedText{(${runNrs[0]})}} & \\multicolumn{4}{|c|}{\\bf temp. 0.25 \\ChangedText{(${runNrs[1]})}} & \\multicolumn{4}{|c|}{\\bf temp. 0.50 \\ChangedText{(${runNrs[2]})}} & \\multicolumn{4}{|c}{\\bf temp. 1.0 \\ChangedText{(${runNrs[3]})}} \\\\
& \\multicolumn{4}{|c|}{\\bf temp. 0.0 \\ChangedText{(${
runNrs[0]
})}} & \\multicolumn{4}{|c|}{\\bf temp. 0.25 \\ChangedText{(${
runNrs[1]
})}} & \\multicolumn{4}{|c|}{\\bf temp. 0.50 \\ChangedText{(${
runNrs[2]
})}} & \\multicolumn{4}{|c}{\\bf temp. 1.0 \\ChangedText{(${
runNrs[3]
})}} \\\\
& \\Total & \\Killed & \\Survived & \\Timeout
& \\Total & \\Killed & \\Survived & \\Timeout
& \\Total & \\Killed & \\Survived & \\Timeout
Expand Down
167 changes: 0 additions & 167 deletions benchmark/computeVariability.ts

This file was deleted.

32 changes: 28 additions & 4 deletions benchmark/generateMutantsTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,19 @@ export function generateMutantsTable(dirName: string, runNr: number): string {
const nrMutants = nrKilled + nrSurvived + nrTimedOut;
const mutScore = jsonStrykerObj.mutationScore;

result += `\\textit{${projectName}} & ${nrPrompts} & \\ChangedText\{${numberWithCommas(nrCandidates)}\} & \\ChangedText\{${numberWithCommas(nrSyntacticallyInvalid)}\} & \\ChangedText\{${numberWithCommas(nrIdentical)}\} & \\ChangedText\{${numberWithCommas(nrDuplicate)}\} & ${numberWithCommas(nrMutants)} & ${numberWithCommas(nrKilled)} & ${numberWithCommas(nrSurvived)} & ${numberWithCommas(nrTimedOut)} & ${parseFloat(
mutScore
).toFixed(2)} \\\\ \n`;
result += `\\textit{${projectName}} & ${nrPrompts} & \\ChangedText\{${numberWithCommas(
nrCandidates
)}\} & \\ChangedText\{${numberWithCommas(
nrSyntacticallyInvalid
)}\} & \\ChangedText\{${numberWithCommas(
nrIdentical
)}\} & \\ChangedText\{${numberWithCommas(
nrDuplicate
)}\} & ${numberWithCommas(nrMutants)} & ${numberWithCommas(
nrKilled
)} & ${numberWithCommas(nrSurvived)} & ${numberWithCommas(
nrTimedOut
)} & ${parseFloat(mutScore).toFixed(2)} \\\\ \n`;

totalNrPrompts += nrPrompts;
totalNrCandidates += nrCandidates;
Expand All @@ -175,7 +185,21 @@ export function generateMutantsTable(dirName: string, runNr: number): string {
totalNrTimedOut += nrTimedOut;
}
result += `\\hline\n`;
result += `\\textit{Total} & ${numberWithCommas(totalNrPrompts)} & \\ChangedText\{${numberWithCommas(totalNrCandidates)}\} & \\ChangedText\{${numberWithCommas(totalNrSyntacticallyInvalid)}\} & \\ChangedText\{${numberWithCommas(totalNrIdentical)}\} & \\ChangedText\{${numberWithCommas(totalNrDuplicate)}\} & ${numberWithCommas(totalNrMutants)} & ${numberWithCommas(totalNrKilled)} & ${numberWithCommas(totalNrSurvived)} & ${numberWithCommas(totalNrTimedOut)} & --- \\\\ \n`;
result += `\\textit{Total} & ${numberWithCommas(
totalNrPrompts
)} & \\ChangedText\{${numberWithCommas(
totalNrCandidates
)}\} & \\ChangedText\{${numberWithCommas(
totalNrSyntacticallyInvalid
)}\} & \\ChangedText\{${numberWithCommas(
totalNrIdentical
)}\} & \\ChangedText\{${numberWithCommas(
totalNrDuplicate
)}\} & ${numberWithCommas(totalNrMutants)} & ${numberWithCommas(
totalNrKilled
)} & ${numberWithCommas(totalNrSurvived)} & ${numberWithCommas(
totalNrTimedOut
)} & --- \\\\ \n`;
result += createTableFooter(dirName, runNr);
return result;
}
Expand Down
17 changes: 12 additions & 5 deletions benchmark/generateVariabilityTable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import fs from "fs";
import path from "path";
import { parse } from "yargs";

function numberWithCommas(x: number): string {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

const projectNames = [
"Complex.js",
Expand Down Expand Up @@ -117,7 +120,7 @@ export function generateVariabilityTable(
runs: string[]
): string {
let latexTable = `
% table generated using command: "node benchmark/computeVariability.js ${baseDir} ${runs.join(
% table generated using command: "node benchmark/generateVariabilityTable.js ${baseDir} ${runs.join(
" "
)}"
\\begin{table}[hbt!]
Expand All @@ -137,9 +140,13 @@ export function generateVariabilityTable(
);
const commonMutants = findCommonMutants(baseDir, runs, projectName);
const percentage = commonMutants.size / allMutantsSize;
latexTable += `${projectName} & ${minMutants} & ${maxMutants} & ${allMutantsSize} & ${
commonMutants.size
} (${(percentage * 100).toFixed(2)}\\%) \\\\ \n`;
latexTable += `${projectName} & ${numberWithCommas(
minMutants
)} & ${numberWithCommas(maxMutants)} & ${numberWithCommas(
allMutantsSize
)} & ${numberWithCommas(commonMutants.size)} (${(percentage * 100).toFixed(
2
)}\\%) \\\\ \n`;
}
const modelName = getModelName(baseDir, runs[0]);
const temperature = getTemperature(baseDir, runs[0]);
Expand Down

0 comments on commit 674c845

Please sign in to comment.