Skip to content

Commit 294e581

Browse files
committed
Move calculation benchmark files to dedicated directory
1 parent 60e33ec commit 294e581

File tree

9 files changed

+73
-0
lines changed

9 files changed

+73
-0
lines changed

Diff for: bin-calculation.js renamed to bucket-calc/main.js

File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: bucket-calc/main.nix

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
let
2+
# # Calculate the power of a base to a floating-point exponent.
3+
# pow = base: exponent:
4+
# if exponent == 0.0
5+
# then 1.0
6+
# else if exponent > 0.0
7+
# then base * (intPow base (builtins.floor exponent))
8+
# else 1.0 / (intPow base (builtins.floor (-exponent)));
9+
10+
# Modulo function for floating-point numbers
11+
mod = n: d:
12+
n - (builtins.floor (n / d)) * d;
13+
14+
# Calculate the power of a base to an integer exponent.
15+
intPow = base: exponent:
16+
if exponent == 0
17+
then 1
18+
else
19+
if exponent > 0
20+
then base * (intPow base (exponent - 1))
21+
else 1 / (intPow base (-exponent));
22+
23+
# Root calculation (using approximation)
24+
root = x: n: # (Approximates the n-th root of x)
25+
let
26+
approx = x;
27+
rec_ = approx: approx * ((n - 1) + x / (intPow approx (n - 1))) / n;
28+
in builtins.trace rec_ rec_; # Adjust iterations as needed
29+
30+
# Our revised pow function
31+
pow = x: y:
32+
if mod y 1 == 0 then # Integer exponent
33+
intPow x y
34+
else
35+
let
36+
p = builtins.floor y;
37+
q = y - p;
38+
in intPow (root x ((1 / q))) p;
39+
40+
# round = x:
41+
# let
42+
# intPart = builtins.floor x; # Get the integer part
43+
# fracPart = x - intPart; # Get the fractional part
44+
# in
45+
# if fracPart < 0.5 then intPart else intPart + 1;
46+
47+
# # Constants
48+
# start = 1.0;
49+
# end = 100000.0;
50+
# numBins = 20.0;
51+
52+
# # Calculating the base of the logarithm
53+
# logBase = pow (end / start) (1.0 / numBins);
54+
55+
# # Recursive function to calculate bin edges
56+
# calcBinEdges = n: acc: if n > numBins
57+
# then acc
58+
# else calcBinEdges (n + 1) (acc ++ [(start*(pow logBase n))]);
59+
60+
# # Initializing calculation with n = 0 and an empty accumulator
61+
# binEdges = calcBinEdges 0 [];
62+
63+
# # Rounding the bin edges to the nearest integer
64+
# binEdgesInt = map (edge: round edge) binEdges;
65+
66+
in
67+
pow 5 0.2

Diff for: bin-calculation.py renamed to bucket-calc/main.py

File renamed without changes.

Diff for: bin-calculation.ts renamed to bucket-calc/main.ts

File renamed without changes.
File renamed without changes.

Diff for: readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ Benchmark for interpreted languages.
1515
- [Python]
1616
- [Lua]
1717
- [Nickel]
18+
- [Nix Language]
1819
- [Typst]
1920

2021
[Bun]: https://bun.sh/
2122
[Deno]: https://deno.com/
2223
[Lua]: https://www.lua.org/
2324
[Nickel]: https://nickel-lang.org/
25+
[Nix Language]: https://nixos.org/manual/nix/stable/language/
2426
[Node.js]: https://nodejs.org/
2527
[Python]: https://www.python.org/
2628
[Typst]: https://typst.app/docs/

Diff for: shebang-scripts/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/today/.bsp
2+
/today/.scala-build
3+
/today/roc
4+
/today/v

0 commit comments

Comments
 (0)