Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experiment: avoid boxing in collections/src/Random.mo #106

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
8 changes: 5 additions & 3 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
MOC_VERSION: 0.10.4
IC_WASM_VERSION: 0.7.0
RUSTC_VERSION: 1.75.0
MOC_ARTIFACT: 1242507845
steps:
- uses: actions/checkout@v3
- name: Checkout out gh-pages report
Expand Down Expand Up @@ -64,9 +65,10 @@ jobs:
chmod a+x /usr/local/bin/ic-repl
npm i -g ic-mops
dfx cache install
cd $(dfx cache show)
wget https://github.com/dfinity/motoko/releases/download/$MOC_VERSION/motoko-Darwin-x86_64-$MOC_VERSION.tar.gz
tar zxvf motoko-Darwin-x86_64-$MOC_VERSION.tar.gz
wget https://nightly.link/dfinity/motoko/actions/artifacts/$MOC_ARTIFACT.zip
unzip $MOC_ARTIFACT.zip
chmod a+x bin/moc
cp -rf bin/moc $(dfx cache show)
wget https://github.com/dfinity/ic-wasm/releases/download/$IC_WASM_VERSION/ic-wasm-macos
cp ./ic-wasm-macos /usr/local/bin/ic-wasm
chmod a+x /usr/local/bin/ic-wasm
Expand Down
4 changes: 2 additions & 2 deletions collections/motoko/src/ZhenyaHashmap.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import Iter "mo:base/Iter";
import Option "mo:base/Option";
import Random "random";
import Profiling "../../../utils/motoko/Profiling";

import Prim "mo:prim";
actor {
stable let profiling = Profiling.init();

func f_hash(x : Nat64) : Nat32 = Hash.hash(Nat64.toNat x);
let hash : HashMap.HashUtils<Nat64> = (f_hash, Nat64.equal);
stable var map = HashMap.new<Nat64, Nat64>();
Expand Down
2 changes: 1 addition & 1 deletion collections/motoko/src/hashmap.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Profiling "../../../utils/motoko/Profiling";

actor {
stable let profiling = Profiling.init();

func hash(x: Nat64) : Nat32 = Hash.hash(Nat64.toNat x);
var map = HashMap.HashMap<Nat64, Nat64>(0, Nat64.equal, hash);
stable var stableMap: [(Nat64, Nat64)] = [];
Expand Down
2 changes: 1 addition & 1 deletion collections/motoko/src/random.mo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module {
};
};
state := state * 48271 % modulus;
?state;
?(state >> 4);
};
};
public func get_memory(): (Nat,Nat,Nat) {
Expand Down
Loading