[erlang-questions] The inner workings of erlang:element/2
Adam Krupicka
akrupicka@REDACTED
Thu Sep 10 14:14:36 CEST 2015
Excerpts from Björn Gustavsson's message of 2015-09-10 13:02:02 +0200:
> On Thu, Sep 10, 2015 at 11:01 AM, Adam Krupicka <akrupicka@REDACTED> wrote:
> > Hello,
> >
> > I was recently profiling some code and noticed that erlang:element/2
> > doesn't show up in neither eprof nor fprof. How is this possible? Is the
> > compiler being smart here and rewriting
> >
> > X = erlang:element(3, A)
> >
> > with
> >
> > {_, _, X} = A?
> >
>
> No. element/2 is implemented using a special instruction (or
> actually one of several different instructions depending on
> the context of the call).
>
> In general, any BIF that may be called in a guard are
> implemented using instructions that don't support
> tracing (i.e. don't show up in eprof/fprof).
>
> /Bjorn
>
I see. Thanks for the reply, makes things clearer.
A. K.
More information about the erlang-questions
mailing list