Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Terrell terrelln

View GitHub Profile
@terrelln
terrelln / measure-linux-decompress.cpp
Created Apr 1, 2020
Measures the time it takes to decompress the linux kernel
View measure-linux-decompress.cpp
#include <chrono>
#include <stdio.h>
namespace {
void wait_for_needle(char const* needle) {
char const* suffix = needle;
while (*suffix != '\0') {
auto const c = getc(stdin);
if (c == *suffix) {
++suffix;
View zstd-dsb-repro.sh
#!/usr/bin/env sh
set -e
# Use this script to check if your platform has instability.
# Set ENWIK8 to the data you want to test. It doesn't necessarily
# have to be enwik8, any data should have the same results, but that
# is what I used. If you don't have it on your machine, just use another
# largeish file. Set COMPILERS to the compilers you want to test.
# It is good if the DSB cycles are always high and the MITE cycles are
View AOC-2019-03.rs
use std::collections::HashMap;
fn to_wire(wire: &str) -> HashMap<(i32, i32), i32> {
let mut c: (i32, i32) = (0, 0);
let mut v = HashMap::new();
let mut s = 1;
for dir in wire.split(",") {
let n: i32 = dir[1..].parse().unwrap();
for _ in 0..n {
if dir.starts_with("L") {
View test.c
#define ZSTD_STATIC_LINKING_ONLY
#include <zstd.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
void compress(ZSTD_CStream *ctx, ZSTD_outBuffer out, const void *data, size_t size) {
ZSTD_inBuffer in = { data, size, 0 };
while (in.pos < in.size) {
ZSTD_outBuffer tmp = out;
View strict-aliasing.h
#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long))
typedef struct {
union {
struct LZ4_stream_t_internal internal;
long long table[LZ4_STREAMSIZE_U64];
};
} LZ4_stream_t;
View test.md

Test commands

> echo "Hello world" | zstd -o test.zst
> zstdcat test.zst
Hello world
> vim test.zst
GA<ENTER>Hello<ESC>:wq<ENTER>
> zstdcat test.zst
Hello world
Hello
View zstd.patch
runtime/doc/pi_gzip.txt | 1 +
runtime/doc/usr_23.txt | 3 +++
runtime/plugin/gzip.vim | 6 +++++-
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/runtime/doc/pi_gzip.txt b/runtime/doc/pi_gzip.txt
index 31cd81b..f76507e 100644
--- a/runtime/doc/pi_gzip.txt
+++ b/runtime/doc/pi_gzip.txt
@@ -27,6 +27,7 @@ with these extensions:
View elision.cpp
#include <iostream>
struct skeleton {
skeleton() { std::cout << "skeleton()" << std::endl; }
skeleton(const skeleton&) { std::cout << "skeleton(const skeleton&)" << std::endl; }
skeleton(skeleton&) { std::cout << "skeleton(skeleton&)" << std::endl; }
skeleton(const skeleton&&) { std::cout << "skeleton(const skeleton&&)" << std::endl; }
skeleton(skeleton&&) { std::cout << "skeleton(skeleton&&)" << std::endl; }
skeleton& operator=(const skeleton&) {
View monstrous.cpp
#include <stdlib.h>
#include <cstdlib>
#include <cstddef>
#include <iostream>
namespace monstrous {
struct DataNode;
/**
* The global variable for the linked list.
View conditional_test.cpp
#include <cassert>
// -std=c++11
struct M {
M() { }
M(const M&) { }
M(M&&) { }
M(const M&&) /* { assert(0); } // */ = delete;
};
You can’t perform that action at this time.