Skip to content

LockFreeQueue vs List #3

@LouisJenkinsCS

Description

@LouisJenkinsCS
use LockFreeQueue;
use List;
use Time;

config const N  = 1024 * 1024 * 16;

var timer = new Timer();
var queue = new owned LockFreeQueue(int);
var l = new list(int, parSafe=true);

timer.start();
forall i in 1..N do queue.enqueue(i);
forall i in 1..N do queue.dequeue();
queue.tryReclaim();
timer.stop();
writeln("LFQ (No Token): ", timer.elapsed());
timer.clear();

timer.start();
forall i in 1..N with (var token = queue.getToken()) do queue.enqueue(i, token);
forall i in 1..N with (var token = queue.getToken()) do queue.dequeue(token);
queue.tryReclaim();
timer.stop();
timer.elapsed();
writeln("LFQ (Token): ", timer.elapsed());
timer.clear();

timer.start();
forall i in 1..N with (ref l) do l.append(i);
forall i in 1..N with (ref l) do l.pop(1);
timer.stop();
writeln("List: ", timer.elapsed());
timer.clear();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions