Skip to content

Instantly share code, notes, and snippets.

View crsaracco's full-sized avatar

Charles Saracco crsaracco

View GitHub Profile
@crsaracco
crsaracco / main.rs
Created June 2, 2020 00:22
bench_min
#![feature(test)] extern crate test;
fn main() {
}
fn manual_min(a: usize, b: usize) -> usize {
if a < b {
a
} else {
b
@crsaracco
crsaracco / main.rs
Created December 15, 2019 06:45
crossbeam_channel allocation test
use std::alloc::{System, GlobalAlloc, Layout};
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst, AtomicBool};
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use crossbeam_channel::bounded;
struct Allocator;
static ALLOCATIONS: AtomicUsize = AtomicUsize::new(0);
@crsaracco
crsaracco / main.rs
Last active September 15, 2019 22:45
backtrace
[INFO][gfx_backend_vulkan]
GENERAL [Loader Message (0)] : Device Extension: VK_NVX_multiview_per_view_attributes (libGLX_nvidia.so.0) version 0.0.1
object info: (type: INSTANCE, hndl: 93960781290048)
[ERROR][gfx_backend_vulkan]
VALIDATION [NVIDIA (1)] : vkBindImageMemory: memoryOffset 2a00 is not aligned to 400
object info: (type: IMAGE, hndl: 140345841030128)
thread '<unnamed>' panicked at 'internal error: entered unreachable code', /home/crs/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx-backend-vulkan-0.2.3/src/device.rs:1311:18
stack backtrace:
@crsaracco
crsaracco / main.rs
Last active September 7, 2019 15:30
Shape generation
use amethyst::utils::application_root_dir;
use amethyst::SimpleState;
use amethyst::GameDataBuilder;
use amethyst::Application;
use amethyst::renderer::{
plugins::{RenderPbr3D, RenderToWindow},
types::DefaultBackend,
RenderingBundle,
};
use amethyst::window::DisplayConfig;
@crsaracco
crsaracco / main.rs
Created August 30, 2019 03:59
first-order feed-forward filter
use std::path::Path;
use std::f64::consts::PI;
use criterion_plot::prelude::*;
mod test_signals;
struct SignalPlot {
name: String,
color: Color,
@crsaracco
crsaracco / benchmarks
Created August 6, 2019 02:21
benchmarks
running 127 tests
test linalg::cholesky::cholesky_100x100_na ... bench: 49,795 ns/iter (+/- 1,070)
test linalg::cholesky::cholesky_100x100_rulinalg ... bench: 55,543 ns/iter (+/- 1,929)
test linalg::cholesky::cholesky_200x200_na ... bench: 359,510 ns/iter (+/- 8,270)
test linalg::cholesky::cholesky_200x200_rulinalg ... bench: 363,149 ns/iter (+/- 7,833)
test linalg::cholesky::cholesky_500x500_na ... bench: 5,697,617 ns/iter (+/- 21,306,798)
test linalg::cholesky::cholesky_500x500_rulinalg ... bench: 5,061,037 ns/iter (+/- 89,224)
test linalg::cholesky::cholesky_unpack_100x100_na ... bench: 50,275 ns/iter (+/- 1,445)
test linalg::cholesky::cholesky_unpack_100x100_rulinalg ... bench: 58,819 ns/iter (+/- 2,515)
test linalg::cholesky::cholesky_unpack_200x200_na ... bench: 361,116 ns/iter (+/-
@crsaracco
crsaracco / main.rs
Created January 30, 2019 09:06
Boxed FnMut
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
////////////////////////////////////////////////////////////////////////////////////////////////////
trait WindowImpl {
fn new() -> PlatformWindow where Self: Sized;
fn set_callback(&mut self, event_handler: Box<FnMut()>);
fn call_callback(&mut self);
}
@crsaracco
crsaracco / main.rs
Created January 30, 2019 08:52
boxed handler
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
////////////////////////////////////////////////////////////////////////////////////////////////////
trait WindowImpl {
fn new() -> PlatformWindow where Self: Sized;
fn set_callback(&mut self, events: Box<dyn EventHandler>);
fn call_callback(&mut self);
}
@crsaracco
crsaracco / error.txt
Created January 30, 2019 01:37
rtb-rs-tester error
Compiling rtb-rs-tester v0.1.0 (/home/crs/git/rtb-rs/rtb-rs-tester)
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> src/editor.rs:58:13
|
58 | handler
| ^^^^^^^
|
@crsaracco
crsaracco / main.cpp
Last active September 26, 2018 04:06
Functional FizzBuzz
#include <iostream>
#include <functional>
using namespace std::placeholders;
bool ReplaceNumber(int a, int mod, std::string replacement) {
if (a%mod == 0) {
std::cout << replacement;
return true;
}