Table of Contents
Fetching ...

Performance Comparison of Function Evaluation Methods

Leo Liberti

TL;DR

The paper compares four function-evaluation methods—black-box functions, binary trees, $n$-ary trees, and string parsing—by evaluating eight two-variable expressions involving $x$ and $y$ over 5,000 random input pairs. Implementations are realized in pure C using a unified tree structure capable of representing both binary and $n$-ary expressions, with a direct string-parser approach for comparison. Initial results report that $n$-ary trees are the fastest, followed by black-box, binary trees, and string parsing, but an important warning later notes a coding mistake that invalidates the main conclusion about the fastest method. The discussion attributes the $n$-ary advantage to reduced recursion for long sequences and highlights the sensitivity of outcomes to compiler optimizations and memory caching, providing guidance for practitioners while stressing the need for careful validation.

Abstract

We perform a comparison of the performance and efficiency of four different function evaluation methods: black-box functions, binary trees, $n$-ary trees and string parsing. The test consists in evaluating 8 different functions of two variables $x,y$ over 5000 floating point values of the pair $(x,y)$. The outcome of the test indicates that the $n$-ary tree representation of algebraic expressions is the fastest method, closely followed by black-box function method, then by binary trees and lastly by string parsing.

Performance Comparison of Function Evaluation Methods

TL;DR

The paper compares four function-evaluation methods—black-box functions, binary trees, -ary trees, and string parsing—by evaluating eight two-variable expressions involving and over 5,000 random input pairs. Implementations are realized in pure C using a unified tree structure capable of representing both binary and -ary expressions, with a direct string-parser approach for comparison. Initial results report that -ary trees are the fastest, followed by black-box, binary trees, and string parsing, but an important warning later notes a coding mistake that invalidates the main conclusion about the fastest method. The discussion attributes the -ary advantage to reduced recursion for long sequences and highlights the sensitivity of outcomes to compiler optimizations and memory caching, providing guidance for practitioners while stressing the need for careful validation.

Abstract

We perform a comparison of the performance and efficiency of four different function evaluation methods: black-box functions, binary trees, -ary trees and string parsing. The test consists in evaluating 8 different functions of two variables over 5000 floating point values of the pair . The outcome of the test indicates that the -ary tree representation of algebraic expressions is the fastest method, closely followed by black-box function method, then by binary trees and lastly by string parsing.

Paper Structure

This paper contains 12 sections, 2 figures, 1 table.

Figures (2)

  • Figure 1: Binary tree representation for $x+y+1$.
  • Figure 2: $n$-ary tree representation for $x+y+1$.