-
Notifications
You must be signed in to change notification settings - Fork 19
Return timing data in response header(s) #438
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
94b3fd5
wip
onpaws 8466d6b
Use an explicit timing approach
onpaws f7e2995
Drop Warp built-in timing
onpaws 6b32a62
Adopt a new header name
onpaws 1931ab2
Extract Timer code into own impl
onpaws d71d738
Keep fmt happy
onpaws c836955
Test for presence of QUERY_TIME_HEADER in uncached read response
onpaws 1bb617d
Include both GET and POST coverage in test
onpaws 1e48150
Use Rust triple slash comments
onpaws b0307b8
Use time directly and drop Option wrapping
onpaws 1071e86
Use Instant directly
onpaws 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ pub mod http; | |
| pub mod http_utils; | ||
| #[cfg(feature = "frontend-postgres")] | ||
| pub mod postgres; | ||
| pub mod profile_utils; | ||
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,34 @@ | ||
| use std::time::{Duration, Instant}; | ||
|
|
||
| // Simple timer intended for profiling | ||
| // Lazily inits. Returns `Duration`s or raw string (in ms) | ||
| // Use Option as a safeguard because apparently previous Rust versions panicked | ||
| // when current time was earlier than self. | ||
|
|
||
| #[derive(Default)] | ||
| pub struct Timer { | ||
| start_time: Option<Instant>, | ||
| } | ||
|
|
||
| impl Timer { | ||
| pub fn new() -> Self { | ||
| Self { start_time: None } | ||
| } | ||
|
|
||
| pub fn start_timer(&mut self) { | ||
| self.start_time = Some(Instant::now()) | ||
| } | ||
|
|
||
| pub fn elapsed(&self) -> Option<Duration> { | ||
| self.start_time.map(|start| start.elapsed()) | ||
| } | ||
onpaws marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| pub fn formatted_elapsed(&self) -> String { | ||
| self.elapsed() | ||
| .map(|duration| { | ||
| let millis = duration.as_millis(); | ||
| format!("{}", millis) | ||
| }) | ||
| .unwrap_or_else(String::new) | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.