Skip to content

Instantly share code, notes, and snippets.

👁
is it real life?

Clément Renault Kerollmops

👁
is it real life?
Block or report user

Report or block Kerollmops

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Kerollmops
Kerollmops / memlog.sh
Last active Jun 16, 2019
Record memory usage of a process
View memlog.sh
#!/usr/bin/env bash
# usage: memlog.sh $(pidof PROCESS_NAME) [ PATH_FOLDER ]
set -e
PID=$1
FOLDER=$2
LOG=./$PID.log
@Kerollmops
Kerollmops / group-by-generic-function.rs
Created Jan 31, 2019
Generic function type thta is in fact a function pointer (`fn` != `Fn`)
View group-by-generic-function.rs
fn linear_group(&self) -> LinearGroupBy<T, fn(&T, &T) -> bool>
where T: Ord
{
LinearGroupBy::new(self, |a, b| a == b)
}
@Kerollmops
Kerollmops / all-eq.rs
Created Aug 6, 2018
A function to test if all values of a slice are equal (to the first element).
View all-eq.rs
fn all_eq<T: Eq>(slice: &[T]) -> bool {
match slice.split_first() {
Some((first, others)) => others.iter().all(|x| x == first),
None => true,
}
}
#[test]
fn all_eq_easy_eq() {
assert!(all_eq(&[1, 1, 1, 1, 1]));
@Kerollmops
Kerollmops / split-first.rs
Created Aug 6, 2018
The `split_first` function for any iterator
View split-first.rs
// prefer using IntoIterator ?
fn split_first<T, I>(mut iter: I) -> Option<(T, I)>
where I: Iterator<Item=T>
{
match iter.next() {
Some(first) => Some((first, iter)),
None => None,
}
}
@Kerollmops
Kerollmops / kero_solution.rs
Created Mar 22, 2018
Different solutions to create a KernelBuilder
View kero_solution.rs
pub enum Arg {
Int(i32),
Float(f32),
String(String),
Ptr(isize),
}
pub enum KernelError {
KernelInvalid,
}
View core-coding-standard.md

Core Coding Standard

Coding practices are a source of a lot of arguments among programmers. Coding standards, to some degree, help us to put certain questions to bed and resolve stylistic debates. No coding standard makes everyone happy. (And even their existence is sure to make some unhappy.) What follows are the standards we put together on the Core team, which have become the general coding standard for all programming teams on new code development. We’ve tried to balance the need for creating a common, recognizable and readable code base with not unduly burdening the programmer with minor code formatting concerns.

Table Of Contents

View corona-bench.txt
test async ... bench: 25,129,522 ns/iter (+/- 1,948,456)
test async_cpupool ... bench: 13,895,220 ns/iter (+/- 2,412,441)
test async_cpupool_cpus ... bench: 16,449,300 ns/iter (+/- 7,062,024)
test async_cpupool_many ... bench: 14,118,352 ns/iter (+/- 3,170,100)
test async_cpus ... bench: 11,057,663 ns/iter (+/- 1,546,785)
test async_many ... bench: 14,304,595 ns/iter (+/- 1,966,185)
test corona ... bench: 34,898,721 ns/iter (+/- 204,006,257)
test corona_blocking_wrapper ... bench: 35,851,174 ns/iter (+/- 76,716,240)
test corona_blocking_wrapper_cpus ... bench: 12,601,478 ns/iter (+/- 1,368,466)
test corona_blocking_wrapper_many ... bench: 20,098,071 ns/iter (+/- 84,982,750)
View build.rs
extern crate bindgen;
use std::env;
use std::path::{Path, PathBuf};
fn main() {
println!("cargo:rustc-link-search=framework=/System/Library/Frameworks/");
println!("cargo:rustc-link-lib=framework=OpenCL");
let headers = env::var("CARGO_MANIFEST_DIR").unwrap() + "/opencl22/CL/";
View lib.mir.rs
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn <impl at src/lib.rs:5:1: 9:2>::from(_1: i16) -> Koko {
let mut _0: Koko; // return place
let mut _2: i16;
bb0: {
StorageLive(_2); // bb0[0]: scope 0 at src/lib.rs:7:23: 7:28
_2 = _1; // bb0[1]: scope 0 at src/lib.rs:7:23: 7:28
_0 = Koko { field: move _2 }; // bb0[2]: scope 0 at src/lib.rs:7:9: 7:30
View workshop.rs
#[derive(Debug)]
struct Person {
name: String,
age: u32,
}
impl Person {
fn new(name: String, age: u32) -> Self {
// return Person { name: name, age: age };
Self { name, age }
You can’t perform that action at this time.