davidor / clj-stress-ng

A clojure wrapper for stress-ng.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clj-stress-ng

A clojure wrapper for stress-ng.

Clojars Project

Travis

Usage

To use this library, you need to have stress-ng installed in your system. The instructions can be found here.

Add the following to your project.clj:

[clj-stress-ng "0.1.3"]

Use the library:

(require '[clj-stress-ng.core :as stress-ng])

Execute stress-ng using the cpu stressor and one worker during 10 seconds:

;; equivalent stress-ng command: stress-ng --cpu 1 --timeout 10s
(stress-ng/run {:cpu {:workers 1}} 10)

Execute stress-ng with several stressors and during 5 seconds:

;; stress-ng --cpu 1 --cache 2 --fifo 3 --timeout 5s
(stress-ng/run {:cpu {:workers 1}
                :cache {:workers 2}
                :fifo {:workers 3}} 5)

The only required option for the stressors is the number of workers. Some stressors can be used with different options. For example, the cpu stressor can be executed with the options --cpu-ops and --cpu-method:

;; stress-ng --cpu 1 --cpu-ops 10000 --cpu-method float --timeout 10s
(stress-ng/run {:cpu {:workers 1 :ops 10000 :method "float"}} 10)

The stress-ng function returns a map with 4 fields like this one:

{:cpu   {:bogo-ops 989, :sys-time 0.0, :usr-time 4.78, :real-time 5.03}
 :cache {:bogo-ops 779, :sys-time 0.0, :usr-time 8.05, :real-time 5.0}}

Get a map with the available stressors and the options that they support:

(println stress-ng/available-stressors)

This library has been tested with stress-ng 0.03.11.

License

Copyright (C) 2015 David Ortiz (Barcelona Supercomputing Center). Distributed under the Apache License.

About

A clojure wrapper for stress-ng.

License:Other


Languages

Language:Clojure 100.0%