lib/keyword.3, doc/concepts.tex: Mention performance of keyword arguments.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 3 Aug 2019 15:06:14 +0000 (16:06 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 3 Aug 2019 15:46:23 +0000 (16:46 +0100)
It's surprisingly not that bad.

doc/concepts.tex
lib/keyword.3

index 39dfd2e..6b21109 100644 (file)
@@ -534,6 +534,13 @@ Keyword arguments can be provided in three ways.
   call, which is useful when writing wrapper functions.
 \end{enumerate}
 
+Perhaps surprisingly, keyword arguments have a relatively small performance
+impact.  On the author's aging laptop, a call to a simple function, passing
+two out of three keyword arguments, takes about 30 cycles longer than calling
+a standard function which just takes integer arguments.  On the other hand,
+quite a lot of code is involved in decoding keyword arguments, so code size
+will naturally suffer.
+
 Keyword arguments are provided as a general feature for C functions.
 However, Sod has special support for messages which accept keyword arguments
 (\xref{sec:concepts.methods.keywords}); and they play an essential rĂ´le in
index 0c6e3e6..db5b86d 100644 (file)
@@ -212,6 +212,17 @@ Argument vectors are rather inconvenient to use,
 but are the only practical way in which a caller can decide at runtime
 which arguments to include in a call,
 which is useful when writing wrapper functions.
+.PP
+Perhaps surprisingly,
+keyword arguments have a relatively small performance impact.
+On the author's aging laptop,
+a call to a simple function,
+passing two out of three keyword arguments,
+takes about 30 cycles longer than
+calling a standard function which just takes integer arguments.
+On the other hand,
+quite a lot of code is involved in decoding keyword arguments,
+so code size will naturally suffer.
 .
 .SS Type definitions
 The header file defines two simple structure types.