mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #20132 - nakul02:issue_19223, r=jdm
Profiler for blocked IpcReceiver::recv() <!-- Please describe your changes on the following line: --> Implements feature #19223 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19223 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> WIP. @jdm - this is the new profiler : "Blocked at IPC Receive" Should I dig through all the calls to `ipc::channel` and replace them with this profiled `IpcReceiver`?  <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20132) <!-- Reviewable:end -->
This commit is contained in:
commit
f467bdce1b
27 changed files with 176 additions and 58 deletions
|
@ -16,3 +16,5 @@ profile_traits = {path = "../../../components/profile_traits"}
|
|||
|
||||
# Work around https://github.com/alexcrichton/jemallocator/issues/19
|
||||
servo_allocator = {path = "../../../components/allocator"}
|
||||
servo_config = {path = "../../../components/config"}
|
||||
|
||||
|
|
|
@ -8,5 +8,6 @@ extern crate ipc_channel;
|
|||
extern crate profile;
|
||||
extern crate profile_traits;
|
||||
extern crate servo_allocator;
|
||||
extern crate servo_config;
|
||||
|
||||
mod time;
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
|
||||
use ipc_channel::ipc;
|
||||
use profile::time;
|
||||
use profile_traits::time::ProfilerMsg;
|
||||
use profile_traits::ipc as ProfiledIpc;
|
||||
use profile_traits::time::{ProfilerCategory, ProfilerData, ProfilerMsg};
|
||||
use servo_config::opts::OutputOptions;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
#[test]
|
||||
fn time_profiler_smoke_test() {
|
||||
|
@ -37,6 +41,29 @@ fn time_profiler_stats_test() {
|
|||
assert_eq!(13.2599, odd_max);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn channel_profiler_test() {
|
||||
let chan = time::Profiler::create(&Some(OutputOptions::Stdout(5.0)), None);
|
||||
let (profiled_sender, profiled_receiver) = ProfiledIpc::channel(chan.clone()).unwrap();
|
||||
thread::spawn(move || {
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
profiled_sender.send(43).unwrap();
|
||||
});
|
||||
|
||||
let val_profile_receiver = profiled_receiver.recv().unwrap();
|
||||
assert_eq!(val_profile_receiver, 43);
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
chan.send(ProfilerMsg::Get((ProfilerCategory::IpcReceiver, None), sender.clone()));
|
||||
|
||||
match receiver.recv().unwrap() {
|
||||
// asserts that the time spent in the sleeping thread is more than 1500 milliseconds
|
||||
ProfilerData::Record(time_data) => assert!(time_data[0] > 1.5e3),
|
||||
ProfilerData::NoRecords => assert!(false),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue