All Projects → lemire → Fastmod

lemire / Fastmod

Licence: apache-2.0
A C/C++ header file for fast 32-bit division remainders (and divisibility tests) on 64-bit hardware.

Projects that are alternatives of or similar to Fastmod

React Vtree
React component for efficiently rendering large tree structures
Stars: ✭ 185 (-8.87%)
Mutual labels:  performance
Timemory
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
Stars: ✭ 192 (-5.42%)
Mutual labels:  performance
Awesome Casestudy
📕 Curated list of technical case studies on WebGL and creative development
Stars: ✭ 2,324 (+1044.83%)
Mutual labels:  performance
Easybuggy
Too buggy web application
Stars: ✭ 189 (-6.9%)
Mutual labels:  performance
Longtasks
Long Task API
Stars: ✭ 193 (-4.93%)
Mutual labels:  performance
Elli
Simple, robust and performant Erlang web server
Stars: ✭ 194 (-4.43%)
Mutual labels:  performance
Preload Webpack Plugin
Please use https://github.com/vuejs/preload-webpack-plugin instead.
Stars: ✭ 2,174 (+970.94%)
Mutual labels:  performance
React Perf Devtool
A browser developer tool extension to inspect performance of React components.
Stars: ✭ 2,277 (+1021.67%)
Mutual labels:  performance
The Front End Knowledge You May Not Know
😇 你可能不知道的前端知识点
Stars: ✭ 2,238 (+1002.46%)
Mutual labels:  performance
Bundle Buddy Webpack Plugin
🐐🐐🐐🐐 bundle-buddy-webpack-plugin 🐐🐐🐐🐐
Stars: ✭ 199 (-1.97%)
Mutual labels:  performance
Bootscale
Speedup applications boot by caching require calls
Stars: ✭ 190 (-6.4%)
Mutual labels:  performance
Timeasure
Transparent method-level wrapper for profiling purposes in Ruby
Stars: ✭ 192 (-5.42%)
Mutual labels:  performance
Scaffeine
Thin Scala wrapper for Caffeine (https://github.com/ben-manes/caffeine)
Stars: ✭ 195 (-3.94%)
Mutual labels:  performance
Opencl Intercept Layer
Intercept Layer for Debugging and Analyzing OpenCL Applications
Stars: ✭ 189 (-6.9%)
Mutual labels:  performance
Autowebperf
AutoWebPerf provides a flexible and scalable framework for running web performance audits with arbitrary audit tools including PageSpeedInsights, WebPageTest and more.
Stars: ✭ 199 (-1.97%)
Mutual labels:  performance
Flamethrower
a DNS performance and functional testing utility supporting UDP, TCP, DoT and DoH (by @NS1)
Stars: ✭ 189 (-6.9%)
Mutual labels:  performance
Aimeos Symfony
Symfony e-commerce bundle for professional, ultra fast online shops, complex B2B applications and #gigacommerce
Stars: ✭ 194 (-4.43%)
Mutual labels:  performance
Labjs
Loading And Blocking JavaScript: On-demand parallel loader for JavaScript with execution order dependencies
Stars: ✭ 2,277 (+1021.67%)
Mutual labels:  performance
Cms
GleezCMS - A Light, Simple, Flexible Content Management System
Stars: ✭ 200 (-1.48%)
Mutual labels:  performance
Aws Lambda Power Tuning
AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.
Stars: ✭ 3,040 (+1397.54%)
Mutual labels:  performance

fastmod

Build Status Build Status Code Quality: Cpp

A header file for fast 32-bit division remainders on 64-bit hardware.

How fast? Faster than your compiler can do it!

Compilers cleverly replace divisions by multiplications and shifts, if the divisor is known at compile time. In a hashing benchmark, our simple C code can beat state-of-the-art compilers (e.g., LLVM clang, GNU GCC) on a recent Intel processor (Skylake).

Further reading:

Usage

We support all major compilers (LLVM's clang, GNU GCC, Visual Studio). Users of Visual Studio need to compile to a 64-bit binary, typically by selecting x64 in the build settings.

It is a header-only library but we have unit tests. Assuming a Linux/macOS setting:

make
./unit

The tests are exhaustive and take some time.

Code samples

In C, you can use the header as follows.

#include "fastmod.h"

// unsigned...

uint32_t d = ... ; // divisor, should be non-zero
uint64_t M = computeM_u32(d); // do once

fastmod_u32(a,M,d);// is a % d for all 32-bit unsigned values a.

fastdiv_u32(a,M);// is a / d for all 32-bit unsigned values a.


is_divisible(a,M);// tells you if a is divisible by d

// signed...

int32_t d = ... ; // should be non-zero and between [-2147483647,2147483647]
int32_t positive_d = d < 0 ? -d : d; // absolute value
uint64_t M = computeM_s32(d); // do once

fastmod_s32(a,M,positive_d);// is a % d for all 32-bit a

fastdiv_s32(a,M,d);// is a / d for all 32-bit a

In C++, it is much the same except that every function is in the fastmod namespace so you need to prefix the calls with fastmod:: (e.g., fastmod::is_divisible).

Go version

(Speculative work) 64-bit benchmark

It is an open problem to derive 64-bit divisions that are faster than what the compiler can produce for constant divisors. For comparisons to native % and / operations, as well as bitmasks, we have provided a benchmark with 64-bit div/mod. You can compile these benchmarks with make benchmark. These require C++11. It is not currently supported under Visual Studio.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].