Skip to content

Instantly share code, notes, and snippets.

View AmineDiro's full-sized avatar
👨‍🍳
Cooking

AmineDiro AmineDiro

👨‍🍳
Cooking
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AmineDiro
AmineDiro / System Design.md
Created June 12, 2023 18:39 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@AmineDiro
AmineDiro / dyn.rs
Last active October 6, 2023 09:52
cleancode rust dynamic
use std::{time::Instant, vec};
const N: usize = 10000;
trait Shape {
fn area(&self) -> f32;
}
#[derive(Clone, Copy)]
struct Square {
side: f32,
}
@AmineDiro
AmineDiro / dyn.rs
Last active October 10, 2023 13:20
cleancode rust dynamic
use rand::Rng;
use std::time::Instant;
const N: usize = 1_000_000;
const N_WARMUP: usize = 100;
trait Shape {
fn area(&self) -> f32;
}
#[derive(Clone, Copy)]
struct Square {
side: f32,
@AmineDiro
AmineDiro / enum.rs
Last active October 10, 2023 13:21
cleancode rust enum
use rand::Rng;
use std::time::Instant;
const N: usize = 1_000_000;
const N_WARMUP: usize = 100;
enum Shape {
Rectangle(Rectangle),
Triangle(Triangle),
Square(Square),
}
@AmineDiro
AmineDiro / data_oriented.rs
Last active October 10, 2023 13:21
cleancode rust data oriented
use rand::Rng;
use std::time::Instant;
const N: usize = 1_000_000;
const N_WARMUP: usize = 100;
enum Type {
Rectangle,
Square,
Triangle,
use std::time::Instant;
const N: usize = 10000;
#[derive(Clone, Copy)]
enum Shape {
Rectangle(Rectangle),
Triangle(Triangle),
Square(Square),
Init,
}
use std::time::Instant;
use rand::Rng;
const N_WARMUP: usize = 100;
static SHAPES_COEFF: [f32; 3] = [1.0, 1.0, 0.5];
const N: usize = 1_000_000;
#[derive(Clone, Copy)]
enum Type {
@AmineDiro
AmineDiro / soa.rs
Last active October 9, 2023 20:48
Struct of arrays
use rand::Rng;
use std::time::Instant;
const N: usize = 1_000_000;
const N_WARMUP: usize = 100;
struct Shapes {
rectangles: Vec<Rectangle>,
triangles: Vec<Triangle>,
squares: Vec<Square>,
@AmineDiro
AmineDiro / fast-client.rs
Created November 6, 2023 22:29
reqwest client
#![feature(array_chunks)]
use std::mem;
use std::time::Duration;
use anyhow::Result;
use bytes::Bytes;
use futures::{stream, StreamExt};
use reqwest::{self, Client};
use serde::Serialize;