-
Notifications
You must be signed in to change notification settings - Fork 3.4k
misc: write command durations to a csv file #32938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
cacieprins
wants to merge
16
commits into
develop
Choose a base branch
from
csv-benchmark
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+786
−90
Draft
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a92cd96
perf log automation command
cacieprins b938ad7
write a performance log entry for each command
cacieprins 6ca1bb1
better log entries
cacieprins ef2acf7
changelog
cacieprins b66121a
Merge branch 'develop' into csv-benchmark
cacieprins 39aa6f2
esc
cacieprins 0aa7f21
fail with debug entry if error thrown initializing perf log
cacieprins 8b2e515
reduce serialization
cacieprins 32afcfb
Merge branch 'develop' into csv-benchmark
cacieprins d80bf84
ts
cacieprins 7d56e1b
Merge branch 'develop' into csv-benchmark
cacieprins 39d87cb
back out of async/await modification to command queue
cacieprins 8b4879c
dont throw if automation throws
cacieprins d0af3eb
Merge branch 'develop' into csv-benchmark
cacieprins 0e83ccc
rm numElements - causes serialization issues??
cacieprins 7084eaf
refactor to performance marks, clean up telemetry on the client, make…
cacieprins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/server/lib/automation/commands/record_performance_entry.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import Debug from 'debug' | ||
| import type { CommandPerformanceEntry } from '@packages/types' | ||
| import path from 'path' | ||
| import fs from 'fs/promises' | ||
| import fsSync from 'fs' | ||
|
|
||
| const debug = Debug('cypress-verbose:server:automation:commands:record_performance_entry') | ||
|
|
||
| function logFilePath () { | ||
| return process.env.CYPRESS_INTERNAL_PERFORMANCE_LOG_FILE_PATH ?? path.join(process.cwd(), 'cypress', 'logs') | ||
| } | ||
|
|
||
| function performanceLogsEnabled () { | ||
| return ['1', 'true'].includes(process.env.CYPRESS_INTERNAL_COMMAND_PERFORMANCE_LOGGING ?? 'false') | ||
| } | ||
|
|
||
| const COLUMNS = [ | ||
| 'startTime', | ||
| 'duration', | ||
| 'name', | ||
| 'numElements', | ||
| 'runnableTitle', | ||
| 'spec', | ||
| ] | ||
|
|
||
| export function initializePerformanceLogFile () { | ||
| if (!performanceLogsEnabled()) { | ||
| return | ||
| } | ||
|
|
||
| debug('initializing performance log file: %s', path.join(logFilePath(), 'performance.log')) | ||
|
|
||
| fsSync.mkdirSync(logFilePath(), { recursive: true }) | ||
| fsSync.writeFileSync(path.join(logFilePath(), 'performance.log'), `${COLUMNS.join(',')}\n`, { flag: 'w' }) | ||
| } | ||
|
|
||
| export async function recordPerformanceEntry (entry: CommandPerformanceEntry) { | ||
| debug('recording performance entry %o', entry) | ||
|
|
||
| if (!performanceLogsEnabled()) { | ||
| return | ||
| } | ||
|
|
||
| const { | ||
| startTime, | ||
| duration, | ||
| name, | ||
| detail: { | ||
| numElements, | ||
| runnable: { | ||
| title, | ||
| }, | ||
| spec, | ||
| }, | ||
| } = entry | ||
|
|
||
| await fs.writeFile( | ||
| path.join(logFilePath(), 'performance.log'), | ||
| [startTime, duration, name, numElements, title, spec].join(',') + '\n', | ||
| { flag: 'a' }, | ||
| ) | ||
cacieprins marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cacieprins If this is meant to be a user facing feature - I would not prefix this with
CYPRESS_INTERNALas that is used for truly internal env vars that users should never set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if it's something we want user-facing, it should be a config entry - but that's out of scope for this, I think. This is to prep for benchmarking visibility approaches