Skip to content

carloosaf/gflambe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gflambe 🧯

Package Version Hex Docs

Generate flame graphs from Gleam programs. This is a wrapper for the Erlang library eflambe

Installation

gleam add gflambe

Usage

This library provides two main functions. We'll use string.append as an example subject for the graph.

apply

This method takes a function that returns Nil and a list of options, and generates a flame graph from its execution.

import gflambe
import gleam/string

pub fn main() {
  gflambe.apply(
    fn() {
      let _ = string.append("hello", "world")
      Nil
    },
    [gflambe.OutputDirectory("./test")],
  )
}

capture

This method takes: a tuple with the module name, function name and arity, a number of calls to capture and a list of options. It waits for the function to be called number_of_calls_to_capture times but doesn't run it itself.

import gflambe
import gleam/erlang/process
import gleam/string

pub fn main() {
  process.spawn(fn() {
    process.sleep(500)
    string.append("hello", "world")
  })

  gflambe.capture(GflambeFunction("gleam@string", "append", 2), 1, [])
}

Note

See the eflambe documentation for more information about how the library works and how it gets the data from the execution.

About

Generate flame graphs from Gleam programs, a wrapper for the erlang library eflambe

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages