* move `ExecuteTimings` from `runtime::bank` to `program_runtime::timings` (cherry picked from commit7d32909e17
) # Conflicts: # core/Cargo.toml # ledger/Cargo.toml # programs/bpf/Cargo.lock * Add execute metrics (cherry picked from commitb25e4a200b
) * Add metrics for executor creation (cherry picked from commit848b6dfbdd
) * Add helper macro for `AddAssign`ing with saturating arithmetic (cherry picked from commitdeb9344e49
) * Use saturating_add_assign macro (cherry picked from commit72fc6096a0
) * Consolidate process instruction execution timings to own struct (cherry picked from commit390ef0fbcd
) Co-authored-by: Trent Nelson <trent@solana.com> Co-authored-by: Carl Lin <carl@solana.com>
This commit is contained in:
@ -103,6 +103,15 @@ macro_rules! program_stubs {
|
||||
() => {};
|
||||
}
|
||||
|
||||
/// Convenience macro for `AddAssign` with saturating arithmetic.
|
||||
/// Replace by `std::num::Saturating` once stable
|
||||
#[macro_export]
|
||||
macro_rules! saturating_add_assign {
|
||||
($i:expr, $v:expr) => {{
|
||||
$i = $i.saturating_add($v)
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
pub extern crate bs58;
|
||||
@ -110,3 +119,18 @@ extern crate log as logger;
|
||||
|
||||
#[macro_use]
|
||||
extern crate solana_frozen_abi_macro;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_saturating_add_assign() {
|
||||
let mut i = 0u64;
|
||||
let v = 1;
|
||||
saturating_add_assign!(i, v);
|
||||
assert_eq!(i, 1);
|
||||
|
||||
i = u64::MAX;
|
||||
saturating_add_assign!(i, v);
|
||||
assert_eq!(i, u64::MAX);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user