Skip to content

Instantly share code, notes, and snippets.

View Jensanf's full-sized avatar

Eugene Anfimov Jensanf

View GitHub Profile
@Jensanf
Jensanf / main.go
Created October 6, 2023 11:08
This code benchmarks the performance of Go channels by transmitting a series of timestamped messages. It evaluates the message transmission time in two scenarios: without any delay and with a 100-microsecond delay between message dispatches. The average transmission duration is then displayed on the console.
package main
import (
"fmt"
"time"
)
const msgCount int = 10000
const capacity int = 100
@Jensanf
Jensanf / main.rs
Created October 6, 2023 11:06
This code benchmarks the performance of crossbeam channels in Rust by sending a series of timestamped messages. It measures the message transmission time under two scenarios: with no delay and with a 100-microsecond delay between sending messages. The results, showing the average transmission duration, are printed to the console.
use crossbeam::channel::{bounded, Receiver, Sender};
use std::thread;
use std::time::{Duration, Instant};
const MSG_COUNT: usize = 10_000;
const CAPACITY : usize = 100;
struct Message {
id: usize,
time_send: Instant,