Skip to content

Commit

Permalink
Prevent multithreading in benchmark for comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
maltekuehl committed Sep 19, 2024
1 parent cbdcf2d commit 365dcf9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/benchmark/bench.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ if (!requireNamespace("matrixStats", quietly = TRUE)) {
install.packages("matrixStats")
}

# Disable multithreading (should only use a single thread anyway)
Sys.setenv("OMP_NUM_THREADS" = "1")
Sys.setenv("OPENBLAS_NUM_THREADS" = "1")
Sys.setenv("MKL_NUM_THREADS" = "1")
Sys.setenv("VECLIB_MAXIMUM_THREADS" = "1")
Sys.setenv("NUMEXPR_NUM_THREADS" = "1")

# Load libraries
library(tximport)
library(bench)
Expand Down
8 changes: 8 additions & 0 deletions test/benchmark/bench.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
"""Benchmark pytximport."""

import os
from logging import INFO, getLogger

# Ensure that xarray and numpy are using only one thread
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["VECLIB_MAXIMUM_THREADS"] = "1"
os.environ["NUMEXPR_NUM_THREADS"] = "1"

import numpy as np
import pandas as pd
import pyperf
Expand Down

0 comments on commit 365dcf9

Please sign in to comment.