Skip to content

Commit

Permalink
Add codec benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
matsutomo81 committed Sep 28, 2022
1 parent b62bd28 commit 5d1b980
Show file tree
Hide file tree
Showing 5 changed files with 36,939 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bench/cljam/io/bam/decoder_bench.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(ns cljam.io.bam.decoder-bench
(:require [libra.bench :refer [defbench are]]
[libra.criterium :as c]
[cljam.test-common :as tcommon]
[cljam.io.sam :as sam]))

(defbench decode-bam-alignment-short-bench
(are [f]
(c/quick-bench
(with-open [r (sam/reader f)]
(dorun (sam/read-alignments r))))
tcommon/test-bam-file
tcommon/medium-bam-file
tcommon/codec-benchmark-bam-file))

(defbench decode-bam-alignment-long-bench
(are [f]
(c/quick-bench
(with-open [r (sam/reader f)]
(dorun (vec (take 10000000 (sam/read-alignments r))))))
tcommon/large-bam-file))
31 changes: 31 additions & 0 deletions bench/cljam/io/bam/encoder_bench.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(ns cljam.io.bam.encoder-bench
(:require [libra.bench :refer [defbench are]]
[libra.criterium :as c]
[cljam.test-common :as tcommon]
[cljam.io.sam :as sam]))

(defbench encode-alignment-short-bench
(tcommon/with-before-after {:before (tcommon/prepare-cache!)
:after (tcommon/clean-cache!)}
(are [f]
(with-open
[r (sam/reader f)
w (sam/writer (str tcommon/temp-dir "/encode-alignment-bench.bam"))]
(let [header (sam/read-header r)
aln (sam/read-alignments r)]
(c/quick-bench (sam/write-alignments w aln header))))
tcommon/test-sam-file
tcommon/medium-sam-file
tcommon/codec-benchmark-sam-file)))

(defbench encode-alignment-long-bench
(tcommon/with-before-after {:before (tcommon/prepare-cache!)
:after (tcommon/clean-cache!)}
(are [f]
(with-open
[r (sam/reader f)
w (sam/writer (str tcommon/temp-dir "/encode-alignment-bench.bam"))]
(let [header (sam/read-header r)
aln (sam/read-alignments r)]
(c/quick-bench (sam/write-alignments w (vec (take 2000000 aln)) header))))
tcommon/large-bam-file)))
Binary file added test-resources/bam/codec_benchmark.bam
Binary file not shown.
Loading

0 comments on commit 5d1b980

Please sign in to comment.