Giter Club home page Giter Club logo

Comments (4)

loonatick-src avatar loonatick-src commented on June 12, 2024

Copying the benchmarks here:

import Benchmark
import BMDemos
import Foundation

let benchmarks = {
    let coefficients = Array(stride(from: 0.1, through: 10.0, by: 0.1 * Double.pi))
    Benchmark.defaultConfiguration = .init(
        metrics: [.cpuTotal, .wallClock],
        timeUnits: .automatic,
        warmupIterations: 0,
        scalingFactor: .mega,
        maxDuration: .seconds(10)
    )
    
    Benchmark("Noop") { benchmark in
        for _ in benchmark.scaledIterations {
        }
    }
    
    Benchmark("blackHole(x)") { benchmark in
        var x = 1.13413241e42
        for _ in benchmark.scaledIterations {
            blackHole(x)
        }
    }
    
    Benchmark("sleep(1)",
              configuration: Benchmark.Configuration(scalingFactor: .one)
    ) { benchmark in
        sleep(1)
    }
    
    Benchmark("Naive polynomial") { benchmark in
        let x = 1.13241241e34
        for _ in benchmark.scaledIterations {
            blackHole(polynomialNaive(x, coefficients: coefficients))
        }
    }
}

And this is what the naive polynomial calculation looks like

public func polynomialNaive(_ x: Double, coefficients cs: [Double]) -> Double {
    var result = 0.0
    for (i,c) in cs.enumerated() {
        result += c * pow(x,Double(i))
    }
    return result
}

from package-benchmark.

loonatick-src avatar loonatick-src commented on June 12, 2024

Sorry never mind I blundered, the tabular output seems to be dividing by the scaling factor, and everything works out just fine in that case.

from package-benchmark.

hassila avatar hassila commented on June 12, 2024

You are right, it is now scaled by the inner loop scaling amount by default as it was more intuitive - you can pass --scale if you don't want that scaling. (Except for throughput that is always scaled)

from package-benchmark.

hassila avatar hassila commented on June 12, 2024

(just fyi, the * denotes that the metric is scaled by the scaling factor)

from package-benchmark.

Related Issues (20)

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.