Merge branch 'main' into tracer-ignore-return-event

This commit is contained in:
Saurabh Misra 2024-12-18 14:13:52 -08:00 committed by GitHub
commit ac1373fa20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 18 additions and 36 deletions

View file

@ -59,14 +59,12 @@ export async function createPr(req, res, next) {
const diffContentsMap: Map<string, FileDiffContent> = fileDiffsToMap(diffContents)
// a timestamp format like 2024-01-31-12.59.48
const timestamp = new Date()
.toISOString()
.replace(/:/g, ".")
.replace(/\.\d+Z$/, "")
// Generate a Base36-encoded timestamp
const timestamp = Date.now() // Current timestamp in milliseconds
const encodedTimestamp = timestamp.toString(36) // e.g., 'kf12oi0'
// If you change this, please also change the regex in github-app.ts in the pull_request.closed event
const newBranchName = `codeflash/optimize-${prCommentFields.function_name}-${timestamp}`
const newBranchName = `codeflash/optimize-${prCommentFields.function_name}-${encodedTimestamp}`
const commitMessage =
buildPrTitle(prCommentFields.function_name, prCommentFields.speedup_pct) +
`\n${prCommentFields.optimization_explanation}`

View file

@ -48,8 +48,8 @@ export function buildResultTestReport(
let reportTableMd: string = ""
// Initialize the markdown table
reportTableMd += '| Test | Status | Details |\n';
reportTableMd += '| --------------------------- | ----------------- | ---------------------- |\n';
reportTableMd += '| Test | Status |\n';
reportTableMd += '| --------------------------- | ----------------- |\n';
// Loop through each test type and construct the table rows
for (const [testType, { passed = 0, failed = 0 }] of Object.entries(reportTableDict)) {
@ -74,9 +74,9 @@ export function buildResultTestReport(
}
// Add the row to the markdown table
reportTableMd += `| ${testType} | ${status} | ${detailsNote} |\n`;
reportTableMd += `| ${testType} | ${status} |\n`;
}
reportTableMd += `|📊 Coverage | ${coverage_message} |\n`;
reportTableMd += `|📊 Tests Coverage | ${coverage_message} |\n`;
// Add detailed test outputs below the table
@ -84,9 +84,9 @@ export function buildResultTestReport(
// Only include details for Existing and Generated tests with results
if ((passed > 0) && (testType.includes('Existing') || testType.includes('Generated'))) {
// Add a heading for the test type details
reportTableMd += `#### ${testType} Details\n\n`;
reportTableMd += `<details>\n`;
reportTableMd += `<summary>Click to view details</summary>\n\n`;
reportTableMd += `<summary>${testType} Details</summary>\n\n`;
// Include the relevant test code
if (testType.includes('Existing')) {
@ -107,16 +107,8 @@ export function buildResultTestReport(
// Add the final markdown content (e.g., the feedback section)
const finalMarkdown = `
${reportTableMd}
---
<details>
<summary>📣 **Feedback**</summary>
If you have any feedback or need assistance, feel free to join our Discord community:
[![Discord](https://img.shields.io/badge/Discord-Join%20Our%20Community-7289DA)](https://discord.gg/a9htYNWKDe)
</details>
:loudspeaker: Feedback on this optimization? [![Discord](https://img.shields.io/badge/Discord-Join%20Our%20Community-7289DA)](https://codeflash.ai/discord)
`;
return PR_TEST_REPORT_TEMPLATE.replace(/\{report_table}/g, finalMarkdown)
@ -259,9 +251,7 @@ export async function createStandalonePullRequest(
const prCommentBody = buildResultDetails(prCommentFields)
const prCommentTestReport = buildResultTestReport(prCommentFields, existingTests, generatedTests, coverage_message)
const title: string =
buildPrTitle(prCommentFields.function_name, prCommentFields.speedup_pct) +
` in \`${prCommentFields.file_path}\``
const title: string = buildPrTitle(prCommentFields.function_name, prCommentFields.speedup_pct)
const body: string = `${prCommentHeader}\n` + `${prCommentBody}\n` + `${prCommentTestReport}`
return await createNewPullRequest(

View file

@ -1,5 +1,6 @@
### 📝 **Explanation and details**
<details>
<summary> 📝 Explanation and details</summary>
{optimization_explanation}
---
</details>

View file

@ -1,9 +1,3 @@
### 📄 {speedup_pct} ({speedup_x}) speedup for ***`{function_name}` in `{file_path}`***
## 📄 ***`{function_name}` in `{file_path}`***
### ✨ Performance Summary:
- **Speed Increase:** 📈 **`{speedup_pct}`** (**`{speedup_x}` faster**)
- **Runtime Reduction:** ⏱️ From **`{original_runtime}`** down to **`{best_runtime}`** (best of `{num_runs}` runs)
---
⏱️ Runtime : **`{original_runtime}`** **→** **`{best_runtime}`** (best of `{num_runs}` runs)

View file

@ -1,4 +1,3 @@
### ✅ **Correctness verification**
✅ **Correctness verification report:**
The new optimized code was tested for correctness. The results are listed below:
{report_table}