Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/futures-util/benches/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  bilock.rs

  Sprache: Rust
 

#![feature(test)]
#![cfg(feature = "bilock")]

extern crate test;

use futures::task::Poll;
use futures_test::task::noop_context;
use futures_util::lock::BiLock;

use crate::test::Bencher;

#[bench]
fn contended(b: &mut Bencher) {
    let mut context = noop_context();

    b.iter(|| {
        let (x, y) = BiLock::new(1);

        for _ in 0..1000 {
            let x_guard = match x.poll_lock(&mut context) {
                Poll::Ready(guard) => guard,
                _ => panic!(),
            };

            // Try poll second lock while first lock still holds the lock
            match y.poll_lock(&mut context) {
                Poll::Pending => (),
                _ => panic!(),
            };

            drop(x_guard);

            let y_guard = match y.poll_lock(&mut context) {
                Poll::Ready(guard) => guard,
                _ => panic!(),
            };

            drop(y_guard);
        }
        (x, y)
    });
}

#[bench]
fn lock_unlock(b: &mut Bencher) {
    let mut context = noop_context();

    b.iter(|| {
        let (x, y) = BiLock::new(1);

        for _ in 0..1000 {
            let x_guard = match x.poll_lock(&mut context) {
                Poll::Ready(guard) => guard,
                _ => panic!(),
            };

            drop(x_guard);

            let y_guard = match y.poll_lock(&mut context) {
                Poll::Ready(guard) => guard,
                _ => panic!(),
            };

            drop(y_guard);
        }
        (x, y)
    })
}

Messung V0.5 in Prozent
C=89 H=89 G=88

¤ Dauer der Verarbeitung: 0.8 Sekunden  (vorverarbeitet am  2026-06-23) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.