Skip to content

Instantly share code, notes, and snippets.

View nmoinvaz's full-sized avatar

Nathan Moinvaziri nmoinvaz

  • Phoenix, United States
View GitHub Profile
@nmoinvaz
nmoinvaz / bi_reverse.c
Last active May 5, 2021 01:55
zlib-ng bi-reverse table
#include <stdio.h>
#include <cstdlib>
#include <map>
unsigned bi_reverse(unsigned code, int len) {
/* code: the value to invert */
/* len: its bit length */
unsigned long res = 0;
do {
import sys
if sys.version_info.major < 3:
print('Python 3 or higher is required to run this script')
exit(1)
import os
import argparse
import codecs
import pprint
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": ["checksum_fuzzer", ".git", ".gitattributes", ".github", ".gitignore", ".not-used", ".shellcheckrc", "CMakeFiles", "CMakeLists.txt", "FAQ.zlib", "INDEX.md", "LICENSE.md", "Makefile.in", "README.md", "adler32.c", "adler32_p.h", "arch", "chunkset.c", "chunkset_tpl.h", "cmake", "compare258.c", "compress.c", "configure", "crc32.c", "crc32_p.h", "crc32_tbl.h", "deflate.c", "deflate.h", "deflate_fast.c", "deflate_medium.c", "deflate_p.h", "deflate_quick.c", "deflate_slow.c", "doc", "fallback_builtins.h", "functable.c", "functable.h", "gzguts.h", "gzlib.c", "gzread.c", "gzwrite.c", "infback.c", "inffast.c", "inffast.h", "inffixed_tbl.h", "inflate.c", "inflate.h", "inflate_p.h", "inftrees.c", "inftrees.h", "insert_string.c", "insert_string_tpl.h", "match_tpl.h", "test", "tools", "tr
@nmoinvaz
nmoinvaz / hashtable_mask.txt
Last active July 3, 2020 16:34
Zlib-ng hash table mask results
Results in the comments..
@nmoinvaz
nmoinvaz / switchlevels_burn.py
Last active May 27, 2020 14:31
Zlib-ng switchlevels python burn test script
import os
import random
import argparse
parser = argparse.ArgumentParser(description='Switchlevel burn script')
parser.add_argument('--bin_dir', help='Binaries directory', default='.\\Debug\\')
parser.add_argument('--test_file', help='Test file to compress', default='test/data/lcet10.txt')
args, unknown = parser.parse_known_args()
for y in range(0, 100000):
@nmoinvaz
nmoinvaz / deflateparams.c
Last active May 25, 2020 13:45
Zlib-ng deflate parameter testing tool
/* deflateparams.c -- test deflate under specific conditions
* Copyright (C) 2020 Nathan Moinvaziri
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
add_executable(deflateparams test/deflateparams.c)
configure_test_executable(deflateparams)
target_link_libraries(deflateparams zlib)
*/
@nmoinvaz
nmoinvaz / longest_match_benchmark.cc
Last active May 25, 2020 13:44
Google benchmark for testing longest_match improvements
/* longest_match_benchmark.cc -- test longest_match timing
* Copyright (C) 2020 Nathan Moinvaziri
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
cmake . -A Win32 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL -DWITH_GZFILEOP=ON -DBUILD_SHARED_LIBS=OFF
cmake_minimum_required(VERSION 3.17)
cmake_policy(SET CMP0091 NEW)
Here is zlib level/algorithm mapping:
Level | Algorithm
0 Store
1 Intel deflate quick
2-3 Zlib deflate fast
4-6 Intel deflate medium
7-9 Zlib deflate slow
@nmoinvaz
nmoinvaz / minigzip.py
Created May 23, 2020 03:39
Minigzip compression level test python script
import os
import argparse
parser = argparse.ArgumentParser(description='Minigzip test app')
parser.add_argument('--file', help='File to test', default=None, action='store', required=False)
args, unknown = parser.parse_known_args()
print("Arguments - Known/Unknown")
print(args)
print(unknown)
@nmoinvaz
nmoinvaz / compare258_benchmark.cc
Last active May 25, 2020 13:42
Google benchmark for testing compare258 variants.
/* compare258_benchmark.cc -- test compare258 variants
* Copyright (C) 2020 Nathan Moinvaziri
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
cmake . -A Win32 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL -DWITH_GZFILEOP=ON -DBUILD_SHARED_LIBS=OFF
cmake_minimum_required(VERSION 3.17)
cmake_policy(SET CMP0091 NEW)