English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Performance in Erlang

Online tools

  • When discussing performance, it is necessary to pay attention to the following points about Erlang. Funs is very fast6−In R7B has further optimized it for Funs, and in R

  • use ++ operator−It is necessary to use this operator correctly. The following examples are for execution++the wrong method of operation.

Online Examples

-module(helloworld). 
-export([start/0]). 
start()->
   fun_reverse([H|T]) ->
   fun_reverse(T)++[H]; 
   fun_reverse([]) ->
   [].

When++the operator duplicates its left operand, resulting in a duplicate copy, thus resulting in quadratic complexity.

  • Using strings−If not handled properly, string processing may be slow. In Erlang, you need to consider more how to use strings and choose the appropriate representation. If you use regular expressions, please use STDLIB's re-module instead of the outdated regexp module.

  • BEAM is a stack-based bytecode virtual machine−BEAM is a register-based virtual machine. It has1024a virtual register, used to save temporary values and pass parameters when calling functions. Variables that need to survive after function calls are saved to the stack. BEAM is a thread code interpreter. Each instruction points directly to a word of executable c code, making instruction dispatch very fast.