Skip to content
This repository was archived by the owner on Jul 8, 2024. It is now read-only.
This repository was archived by the owner on Jul 8, 2024. It is now read-only.

Ensure type stability for Julia benchmarks #191

Description

@GiggleLiu

The julia code in this repo is not type stable, which causes more than 10x slow down.

Whenever the type is not stable, Julia can not compile efficient code for you.
For example, using global variables like this would cause type instability.

d = size(means,1)

To avoid type instability, one should

  • avoid using global variables, if it is nessesary, add const keyword.
  • do not change the type of a variable inside a loop,
  • try not using closure if not nessesary,

Type instability can be seen by typing @code_warntype f(x).
For more information, see performance tips
https://docs.julialang.org/en/v1/manual/performance-tips/

Also, please take a look at this package for benchmark.
https://github.com/JuliaCI/BenchmarkTools.jl

Fixing this issue will definitely make the benchmark in your paper more reliable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions