Code Monkey home page Code Monkey logo

power_rapl_erl's Introduction

Energy Profiling for Erlang and Elixir

================================

power_rapl_erl is a tool to provide the profiling energy consumption for Erlang and Elixirfor the whole CPU. power_rapl_erl use Inte's RAPL (Running Average Power Limit) interface to indicate the amount of energy consumed.

How to build power_rapl_erl

To build power_rapl_erl you just need compile the file, indicating where is our erlang/usr/include path:

   $  gcc -fPIC -shared -o rapl_erl.so rapl_erl.c -I /*/erlang/usr/include/

Compile the rapl_nif and rapl_erl files too.

   $ erlc rapl_nif.erl rapl_erl.erl

Remeber to change the permission to access the /dev/cpu/*/msr file, or run your code as root.

IMPORTANT: You need to make sure that the “msr” driver is loaded before you can start using power_rapl_erl. You can do that checking for following directories:

        $ ls /dev/cpu/0/msr

If this directory does not exist. You can load the “msr” module by the following command:

        $ sudo modprobe msr

How to use power_rapl_erl

Run in Erlang:

   1> rapl_erl:start_energy_profiling(fibonacci, fib, [4]).
    Result: 3
       MODULE      |    FUNCTION   |    ENERGY BEFORE      |     ENERGY AFTER      |     ENERGY CONSUMED
    fibonacci      |         fib   |     50267.433258      |     50267.451721      |            0.018463

Run in Elixir:

   iex(1)> :rapl_erl.start_energy_profiling(Fibonacci, :fib, [4])
    Result: 5
        MODULE      |    FUNCTION   |    ENERGY BEFORE      |     ENERGY AFTER      |     ENERGY CONSUMED
    Elixir.Fib      |         fib   |     54245.303635      |     54245.310242      |            0.006607  

power_rapl_erl's People

Contributors

filipevarjao avatar leofernandesmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.