Skip to main content

Profiler

Struct Profiler 

Source
pub struct Profiler { /* private fields */ }
Expand description

Counts what a run executes, by the instruction that executed.

Implementations§

Source§

impl Profiler

Source

pub fn new() -> Profiler

A profiler with nothing recorded yet.

Source

pub fn counted(&self) -> u64

How many instructions were counted.

Source

pub fn total(&self) -> Cost

What the whole run cost, by the four figures a row carries.

Source

pub fn hottest(&self) -> Vec<((FunctionId, u32), Cost)>

Every instruction that ran, and how often, hottest first.

Ties are broken by the instruction’s own identity, so two runs of one program report the same order: a profile that reordered its own ties would make an unchanged program look changed.

Source

pub fn by_function(&self) -> Vec<(FunctionId, Cost)>

Every function that ran, and what the instructions of it cost, hottest first.

Source

pub fn rows(&self) -> Vec<((FunctionId, u32), Cost)>

Every instruction that ran and what it cost, in no particular order.

For a reader that wants to group by something only the program knows — the opcode an instruction is, the callee a call names — which this crate deliberately does not: a profiler that read the program would have to be given one, and the two things that want these groupings already hold it.

Trait Implementations§

Source§

impl Debug for Profiler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debugger for Profiler

Source§

fn at(&self, stop: &Stop<'_>) -> Resume

Closes the instruction that just ran and opens the one about to.

The count belongs to the instruction this stop is before; the time and the heap belong to the one the previous stop was before, because those are what moved in between.

The clock is read twice, first thing and last thing, and the bookkeeping sits between the two reads. So the interval a number is measured over holds the instruction, the dispatch that reached it and two clock reads — and not this hook’s mutex and map, which is the expensive part and which would otherwise swamp what it is trying to measure. An add.int is a nanosecond or two and the map is a hundred.

Source§

impl Default for Profiler

Source§

fn default() -> Profiler

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.