Skip to content

Instantly share code, notes, and snippets.

View IsuraManchanayake's full-sized avatar
🏠
Working from home

Isura D. Manchanayake IsuraManchanayake

🏠
Working from home
  • University of Melbourne
  • Melbourne
View GitHub Profile
@IsuraManchanayake
IsuraManchanayake / Solution.h
Last active May 16, 2020 19:55
Find edges that appear on every MST and find edges that appear in none of the MSTs.
#pragma once
#include <vector>
#include <map>
#include <unordered_set>
template<typename T>
struct AdjM {
std::vector<T> mat;
size_t V;
@IsuraManchanayake
IsuraManchanayake / demanglify.py
Created June 7, 2019 06:33
Demangle the mangled names in C++ flamegraphs (perf)
import cxxfilt
def toxml(s):
s = str.replace(str(s), '&', '&amp;')
s = str.replace(str(s), '<', '&lt;')
return str.replace(str(s), '>', '&gt;')
def tostr(s):
s = str.replace(str(s), '&gt;', '>')
s = str.replace(str(s), '&lt;', '<')
var maxIterations;
var maxVal;
var height;
var width;
var pointx;
var pointy;
var thresh;
var maxIterations;
var maxVal;
var height;
var width;
function preload() {
maxIterations = 200;
maxVal = 50;
int tt = 10, it = 1;
double total = 0.;
cout << "primality test using primality_miller_rabin_probabilistic(int64_t)" << endl;
cout << "Miller Rabin iteration count = " << it << endl;
cout << "L : " << L << " R : " << R << endl;
for(int k = 0, c = 0, t = clock(); k < tt; k++, c = 0, t = clock()) {
for(int i = L; i <= R; i++)
c += primality_miller_rabin_probabilistic(i, it);
double time = (clock() - t) / (CLOCKS_PER_SEC + 0.);
total += time;
@IsuraManchanayake
IsuraManchanayake / output.txt
Last active December 10, 2016 12:41
deterministic variant of Miller Rabbin method
primality test using primality_miller_rabin(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.861 s
test 2 duration : 0.853 s
test 3 duration : 0.856 s
test 4 duration : 0.844 s
test 5 duration : 0.84 s
test 6 duration : 0.835 s
test 7 duration : 0.839 s
test 8 duration : 0.839 s
primality test using primality_sqrt_bound_coprime_30(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.281 s
test 2 duration : 0.225 s
test 3 duration : 0.222 s
test 4 duration : 0.227 s
test 5 duration : 0.226 s
test 6 duration : 0.223 s
test 7 duration : 0.223 s
test 8 duration : 0.225 s
primality test using primality_sqrt_bound_coprime_6(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.278 s
test 2 duration : 0.269 s
test 3 duration : 0.283 s
test 4 duration : 0.258 s
test 5 duration : 0.263 s
test 6 duration : 0.272 s
test 7 duration : 0.262 s
test 8 duration : 0.265 s
primality test using primality_sqrt_bound_coprime_2(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.418 s
test 2 duration : 0.393 s
test 3 duration : 0.397 s
test 4 duration : 0.406 s
test 5 duration : 0.379 s
test 6 duration : 0.381 s
test 7 duration : 0.383 s
test 8 duration : 0.383 s
primality test using primality_sqrt_bound(int64_t)
L = 100000000 : R = 100100000
test 1 duration : 0.761 s
test 2 duration : 0.762 s
test 3 duration : 0.764 s
test 4 duration : 0.771 s
test 5 duration : 0.741 s
test 6 duration : 0.741 s
test 7 duration : 0.769 s
test 8 duration : 0.744 s