Giter Club home page Giter Club logo

odinperf's Introduction

To run benchmark you first need to build Odin.dll. Make sure you have Odin installed. Open a terminal and navigate to the root of the project. Build the Odin code using:

odin build Odin -build-mode:dll -o:aggressive

This should procuce the necessary Odin.dll in the root of the project. You can now run the benchmark using:

dotnet run -c Release -arch: x64

Note Odin Version: dev-2023-10-nightly:2cca0050

Note For macOS users. Compile the Odin code to a .dylib file

  1. Run odin build Odin -build-mode:dll -out:libOdin -o:aggressive
  2. Add libOdin.dylib to OdinPerf.fsproj analogously: <Content Include="libOdin.dylib">...</Content>
  3. Run dotnet run -c Release -arch: osx or omit -arch entirely.

Results from my machine:

// * Summary *

BenchmarkDotNet v0.13.10, Windows 11 (10.0.22621.2134/22H2/2022Update/SunValley2)
13th Gen Intel Core i9-13900K, 1 CPU, 32 logical and 24 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 DEBUG
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method        | Mean       | Error     | StdDev    |
|-------------- |-----------:|----------:|----------:|
| FSharp_Bench1 | 291.169 us | 2.8295 us | 2.6467 us |
| Odin_Bench1   |   8.233 us | 0.0817 us | 0.0764 us |
| FSharp_Bench2 | 300.321 us | 2.6954 us | 2.3894 us |
| Odin_Bench2   |  12.352 us | 0.2092 us | 0.1956 us |
| FSharp_Min    |  18.401 us | 0.2386 us | 0.2232 us |
| Odin_Min      |   4.351 us | 0.0474 us | 0.0443 us |

odinperf's People

Contributors

matthewcrews avatar aviavni avatar madjazz avatar

Stargazers

 avatar Suraj avatar Luis Ángel Méndez Gort avatar John Montgomery avatar Aistis Raulinaitis avatar

Watchers

 avatar

Forkers

madjazz

odinperf's Issues

Added imperatve FSharp, Go and Zig for comparison

This is on linux.

Method Mean Error StdDev
FSharp 888.5 ns 16.97 ns 25.91 ns
FSharpImp 726.3 ns 5.01 ns 4.69 ns
Odin 177.8 ns 0.19 ns 0.15 ns
Zig 111.5 ns 0.24 ns 0.23 ns
Go 537.2 ns 0.38 ns 0.34 ns
[<Benchmark>]
member _.FSharpImp () =

    for i = 0 to a.Length - 1 do
        fResult[i] <- a[i] + b[i]

    fResult

Go:

Odin definitely makes it easier to handle slices.

package main

import "C"
import "unsafe"

//export addArrays
func addArrays(result, a, b *C.double, length C.int) {
	resultSlice := (*[1 << 30]C.double)(unsafe.Pointer(result))[:length:length]
	aSlice := (*[1 << 30]C.double)(unsafe.Pointer(a))[:length:length]
	bSlice := (*[1 << 30]C.double)(unsafe.Pointer(b))[:length:length]

	for i := C.int(0); i < length; i++ {
		resultSlice[i] = aSlice[i] + bSlice[i]
	}
}

func main() {}

Zig:

export fn addArrays(result: [*]f64, a: [*]f64, b: [*]f64, length: usize) void {
    var i: usize = 0; 
    while (i < length) {
        result[i] = a[i] + b[i];
        i += 1;
    }
}

Build:

go build -o main.so -buildmode=c-shared main.go

odin build  main.odin -file  -build-mode:dll -o:speed

zig build-lib -dynamic main.zig -femit-bin=main.so -O ReleaseSafe 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.