Skip to content

Instantly share code, notes, and snippets.

View danielSanchezQ's full-sized avatar
🦀

Daniel Sanchez danielSanchezQ

🦀
View GitHub Profile
from typing import List, Set, TypeAlias, Sequence
from itertools import cycle
NodeId: TypeAlias = bytes
def calculate_subnets(nodes_list: Sequence[NodeId], num_subnets: int, replication_factor: int) -> List[Set[NodeId]]:
"""
Calculate in which subnet(s) to place each node.
verifier fastest │ slowest │ median │ mean │ samples │ iters
╰─ verify │ │ │ │ │
├─ 32 │ │ │ │ │
│ ├─ 128 36.91 ms │ 36.91 ms │ 36.91 ms │ 36.91 ms │ 1 │ 30
│ │ 866.8 B/s │ 866.8 B/s │ 866.8 B/s │ 866.8 B/s │ │
│ ├─ 256 20.77 ms │ 20.77 ms │ 20.77 ms │ 20.77 ms │ 1 │ 30
│ │ 1.54 KB/s │ 1.54 KB/s │ 1.54 KB/s │ 1.54 KB/s │ │
│ ├─ 512 12.56 ms │ 12.56 ms │ 12.56 ms │ 12.56 ms │ 1 │ 30
│ │ 2.546 KB/s │ 2.546 KB/s │ 2.546 KB/s │ 2.546 KB/s │ │
│ ├─ 1024 8.469 ms │ 8.469 ms │ 8.469 ms │ 8.469 ms │ 1 │ 30
encoder fastest │ slowest │ median │ mean │ samples │ iters
╰─ encode │ │ │ │ │
├─ 32 │ │ │ │ │
│ ├─ 128 436.8 ms │ 436.8 ms │ 436.8 ms │ 436.8 ms │ 1 │ 1
│ │ 75.01 KB/s │ 75.01 KB/s │ 75.01 KB/s │ 75.01 KB/s │ │
│ ├─ 256 615 ms │ 615 ms │ 615 ms │ 615 ms │ 1 │ 1
│ │ 53.27 KB/s │ 53.27 KB/s │ 53.27 KB/s │ 53.27 KB/s │ │
│ ├─ 512 1.112 s │ 1.112 s │ 1.112 s │ 1.112 s │ 1 │ 1
│ │ 29.46 KB/s │ 29.46 KB/s │ 29.46 KB/s │ 29.46 KB/s │ │
│ ├─ 1024 1.853 s │ 1.853 s │ 1.853 s │ 1.853 s │ 1 │ 1
@danielSanchezQ
danielSanchezQ / nomos-bench.py
Last active June 4, 2024 13:41
NomosDa benches
from collections import defaultdict
from math import ceil
benches_results = {
"proofs": {
128: 0.28,
256: 0.47,
512: 0.82,
1024: 1.39
},
@danielSanchezQ
danielSanchezQ / const_str_check.rs
Created January 31, 2022 12:53
Compile time str eq
use const_str;
pub trait Foo {
const ID: &'static str;
}
struct A;
struct B;
impl Foo for A {
@danielSanchezQ
danielSanchezQ / flatten_files_and_deserialize.rs
Created May 4, 2021 13:34
Stream deserialized content by appending different files stream data
use std::fs;
use std::io;
use std::io::BufReader;
use std::path::{Path, PathBuf};
use bincode::Options;
type PersistentFragmentLog = String;
struct FileFragments {
#ifndef _MEM_LICKER_
#define _MEM_LICKER_
#include <unordered_map>
#include <iostream>
#include <string>
using namespace std;
using ptr = void*;
struct PtrData

Keybase proof

I hereby claim:

  • I am danielsanchezq on github.
  • I am netwave (https://keybase.io/netwave) on keybase.
  • I have a public key ASBVfZvvkvmyQlUIyK7jDaQsE8e9lIqAhHqjASkaZoIF2Qo

To claim this, I am signing this object:

@danielSanchezQ
danielSanchezQ / MemLicker.hpp
Last active March 12, 2019 11:27
Memory tracking utility
#ifndef _MEM_LICKER_
#define _MEM_LICKER_
#include <unordered_map>
#include <iostream>
#include <string>
using namespace std;
using ptr = void*;
struct PtrData
@danielSanchezQ
danielSanchezQ / functor.rs
Created December 17, 2018 08:10
Functor trait and example rust
trait Functor <A, B, C, F> where F : Fn(&A) -> B {
fn fmap(&self, f: F) -> C;
}
enum List<T> {
Nil,
List(T, Box<List<T>>)
}
impl<A, B, F> Functor<A, B, List<B>, F> for List<A>