\hypertarget{group__Eina__Benchmark__Group}{}\doxysection{Benchmark}
\label{group__Eina__Benchmark__Group}\index{Benchmark@{Benchmark}}


These functions allow you to add a benchmark framework to a project for timing critical parts and detecting slow parts of code.  


\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}{EINA\+\_\+\+BENCHMARK}}(function)~((\mbox{\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}})function)
\begin{DoxyCompactList}\small\item\em Definition for the cast to an \mbox{\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}\label{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}} 
typedef struct \+\_\+\+Eina\+\_\+\+Benchmark {\bfseries Eina\+\_\+\+Benchmark}
\begin{DoxyCompactList}\small\item\em Type for a benchmark. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}\label{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}} 
typedef void($\ast$ {\bfseries Eina\+\_\+\+Benchmark\+\_\+\+Specimens}) (int request)
\begin{DoxyCompactList}\small\item\em Type for a test function to be called when running a benchmark. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$ \mbox{\hyperlink{group__Eina__Benchmark__Group_ga0553fada9227bc8b5b9f9c8bfed9def7}{eina\+\_\+benchmark\+\_\+new}} (const char $\ast$name, const char $\ast$run)
\begin{DoxyCompactList}\small\item\em Creates a new array. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void \mbox{\hyperlink{group__Eina__Benchmark__Group_ga07f1276628b40aac723f21c75b5d5b76}{eina\+\_\+benchmark\+\_\+free}} (\mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$bench)
\begin{DoxyCompactList}\small\item\em Frees a benchmark object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Eina__Benchmark__Group_ga9732a7da5665e92d0afaf0367d2f6b85}{eina\+\_\+benchmark\+\_\+register}} (\mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$bench, const char $\ast$name, \mbox{\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}} bench\+\_\+cb, int count\+\_\+start, int count\+\_\+end, int count\+\_\+step)
\begin{DoxyCompactList}\small\item\em Adds a test to a benchmark. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Array__Group_ga2a57284ee83a7e767485b7ae2f5df86c}{Eina\+\_\+\+Array}} $\ast$ \mbox{\hyperlink{group__Eina__Benchmark__Group_ga0375144e67c0f4ca6f687236bc845cfe}{eina\+\_\+benchmark\+\_\+run}} (\mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$bench)
\begin{DoxyCompactList}\small\item\em Runs the benchmark\textquotesingle{}s registered tests. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
These functions allow you to add a benchmark framework to a project for timing critical parts and detecting slow parts of code. 

It is used in Eina to compare the time used by eina, glib, evas and ecore data types.

To use the benchmark module, Eina must be initialized with \mbox{\hyperlink{group__Eina__Main__Group_ga81b8137665b8a4d2cb38ca50017d4c74}{eina\+\_\+init()}} and later shut down with \mbox{\hyperlink{group__Eina__Main__Group_ga5bf35513199d5220341437c05696285d}{eina\+\_\+shutdown()}}. A benchmark is created with \mbox{\hyperlink{group__Eina__Benchmark__Group_ga0553fada9227bc8b5b9f9c8bfed9def7}{eina\+\_\+benchmark\+\_\+new()}} and freed with \mbox{\hyperlink{group__Eina__Benchmark__Group_ga07f1276628b40aac723f21c75b5d5b76}{eina\+\_\+benchmark\+\_\+free()}}.

\mbox{\hyperlink{group__Eina__Benchmark__Group_ga9732a7da5665e92d0afaf0367d2f6b85}{eina\+\_\+benchmark\+\_\+register()}} adds a test to a benchmark. That test can be run a certain amount of times. Adding more than one test to be executed allows the comparison between several parts of a program, or different implementations.

\mbox{\hyperlink{group__Eina__Benchmark__Group_ga0375144e67c0f4ca6f687236bc845cfe}{eina\+\_\+benchmark\+\_\+run()}} runs all the tests registered with \mbox{\hyperlink{group__Eina__Benchmark__Group_ga9732a7da5665e92d0afaf0367d2f6b85}{eina\+\_\+benchmark\+\_\+register()}}. The amount of time of each test is written in a gnuplot file.

For more information, you can look at the \mbox{\hyperlink{tutorial_benchmark_page}{Benchmark Tutorial}}. 

\doxysubsection{Macro Definition Documentation}
\mbox{\Hypertarget{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}\label{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}} 
\index{Benchmark@{Benchmark}!EINA\_BENCHMARK@{EINA\_BENCHMARK}}
\index{EINA\_BENCHMARK@{EINA\_BENCHMARK}!Benchmark@{Benchmark}}
\doxysubsubsection{\texorpdfstring{EINA\_BENCHMARK}{EINA\_BENCHMARK}}
{\footnotesize\ttfamily \#define EINA\+\_\+\+BENCHMARK(\begin{DoxyParamCaption}\item[{}]{function }\end{DoxyParamCaption})~((\mbox{\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}})function)}



Definition for the cast to an \mbox{\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em function} & The function to cast.\\
\hline
\end{DoxyParams}
This macro casts {\ttfamily function} to Eina\+\_\+\+Benchmark\+\_\+\+Specimens. 

\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Benchmark__Group_ga0553fada9227bc8b5b9f9c8bfed9def7}\label{group__Eina__Benchmark__Group_ga0553fada9227bc8b5b9f9c8bfed9def7}} 
\index{Benchmark@{Benchmark}!eina\_benchmark\_new@{eina\_benchmark\_new}}
\index{eina\_benchmark\_new@{eina\_benchmark\_new}!Benchmark@{Benchmark}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_new()}{eina\_benchmark\_new()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$ eina\+\_\+benchmark\+\_\+new (\begin{DoxyParamCaption}\item[{const char $\ast$}]{name,  }\item[{const char $\ast$}]{run }\end{DoxyParamCaption})}



Creates a new array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em name} & The name of the benchmark. \\
\hline
\mbox{\texttt{ in}}  & {\em run} & The name of the run. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A valid benchmark on success, or {\ttfamily NULL} on memory allocation failure.
\end{DoxyReturn}
This function creates a new benchmark. {\ttfamily name} and {\ttfamily run} are used to name the gnuplot file that \mbox{\hyperlink{group__Eina__Benchmark__Group_ga0375144e67c0f4ca6f687236bc845cfe}{eina\+\_\+benchmark\+\_\+run()}} will create.

When the new module is not needed anymore, use \mbox{\hyperlink{group__Eina__Benchmark__Group_ga07f1276628b40aac723f21c75b5d5b76}{eina\+\_\+benchmark\+\_\+free()}} to free the allocated memory. \mbox{\Hypertarget{group__Eina__Benchmark__Group_ga07f1276628b40aac723f21c75b5d5b76}\label{group__Eina__Benchmark__Group_ga07f1276628b40aac723f21c75b5d5b76}} 
\index{Benchmark@{Benchmark}!eina\_benchmark\_free@{eina\_benchmark\_free}}
\index{eina\_benchmark\_free@{eina\_benchmark\_free}!Benchmark@{Benchmark}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_free()}{eina\_benchmark\_free()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void eina\+\_\+benchmark\+\_\+free (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$}]{bench }\end{DoxyParamCaption})}



Frees a benchmark object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em bench} & The benchmark to free.\\
\hline
\end{DoxyParams}
This function removes all the benchmark tests that have been registered and frees {\ttfamily bench}. If {\ttfamily bench} is {\ttfamily NULL}, this function returns immediately. 

References \mbox{\hyperlink{group__Eina__Array__Group_ga7fa7e2cdcfb739140d5c5a5044086ce1}{eina\+\_\+array\+\_\+free()}}, \mbox{\hyperlink{group__Eina__Array__Group_ga810ed3618ca03f7d549a1bf2c33b2b6e}{EINA\+\_\+\+ARRAY\+\_\+\+ITER\+\_\+\+NEXT}}, \mbox{\hyperlink{group__Eina__Inline__List__Group_gaf885b08d5b5a750a901f3780d3c65338}{eina\+\_\+inlist\+\_\+remove()}}, and \mbox{\hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\+\_\+\+LIST\+\_\+\+FREE}}.

\mbox{\Hypertarget{group__Eina__Benchmark__Group_ga9732a7da5665e92d0afaf0367d2f6b85}\label{group__Eina__Benchmark__Group_ga9732a7da5665e92d0afaf0367d2f6b85}} 
\index{Benchmark@{Benchmark}!eina\_benchmark\_register@{eina\_benchmark\_register}}
\index{eina\_benchmark\_register@{eina\_benchmark\_register}!Benchmark@{Benchmark}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_register()}{eina\_benchmark\_register()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} eina\+\_\+benchmark\+\_\+register (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$}]{bench,  }\item[{const char $\ast$}]{name,  }\item[{\mbox{\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}}}]{bench\+\_\+cb,  }\item[{int}]{count\+\_\+start,  }\item[{int}]{count\+\_\+end,  }\item[{int}]{count\+\_\+step }\end{DoxyParamCaption})}



Adds a test to a benchmark. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em bench} & The benchmark. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & The name of the test. \\
\hline
\mbox{\texttt{ in}}  & {\em bench\+\_\+cb} & The test function to be called. \\
\hline
\mbox{\texttt{ in}}  & {\em count\+\_\+start} & The start data to be passed to {\ttfamily bench\+\_\+cb}. \\
\hline
\mbox{\texttt{ in}}  & {\em count\+\_\+end} & The end data to be passed to {\ttfamily bench\+\_\+cb}. \\
\hline
\mbox{\texttt{ in}}  & {\em count\+\_\+step} & The step data to be passed to {\ttfamily bench\+\_\+cb}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}} on failure, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}} otherwise.
\end{DoxyReturn}
This function adds the test named {\ttfamily name} to {\ttfamily benchmark}. {\ttfamily bench\+\_\+cb} is the function called when the test is executed. That test can be executed a certain number of times, from {\ttfamily count\+\_\+start} to {\ttfamily count\+\_\+end}, with a step increment of {\ttfamily count\+\_\+step}. This counter is passed to {\ttfamily bench\+\_\+cb} when \mbox{\hyperlink{group__Eina__Benchmark__Group_ga0375144e67c0f4ca6f687236bc845cfe}{eina\+\_\+benchmark\+\_\+run()}} is called.

If {\ttfamily bench} is {\ttfamily NULL} or {\ttfamily count\+\_\+step} is 0, this function returns immediately and does not add any tests to the benchmark. 

References \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__Inline__List__Group_gaef650e653f43178ecfee2c661bea7a85}{eina\+\_\+inlist\+\_\+append()}}, \mbox{\hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\+\_\+\+INLIST\+\_\+\+GET}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.

\mbox{\Hypertarget{group__Eina__Benchmark__Group_ga0375144e67c0f4ca6f687236bc845cfe}\label{group__Eina__Benchmark__Group_ga0375144e67c0f4ca6f687236bc845cfe}} 
\index{Benchmark@{Benchmark}!eina\_benchmark\_run@{eina\_benchmark\_run}}
\index{eina\_benchmark\_run@{eina\_benchmark\_run}!Benchmark@{Benchmark}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_run()}{eina\_benchmark\_run()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Array__Group_ga2a57284ee83a7e767485b7ae2f5df86c}{Eina\+\_\+\+Array}} $\ast$ eina\+\_\+benchmark\+\_\+run (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$}]{bench }\end{DoxyParamCaption})}



Runs the benchmark\textquotesingle{}s registered tests. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em bench} & The benchmark. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A list of gnuplot filenames for the test results, or {\ttfamily NULL} on failure.
\end{DoxyReturn}
This function runs all the tests that have been registered with \mbox{\hyperlink{group__Eina__Benchmark__Group_ga9732a7da5665e92d0afaf0367d2f6b85}{eina\+\_\+benchmark\+\_\+register()}} and saves the result in gnuplot input files. The filenames have the following format\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{bench\_[name]\_[run]\%s.gnuplot}

\end{DoxyCode}


Where \mbox{[}name\mbox{]} and \mbox{[}run\mbox{]} are the values passed to \mbox{\hyperlink{group__Eina__Benchmark__Group_ga0553fada9227bc8b5b9f9c8bfed9def7}{eina\+\_\+benchmark\+\_\+new()}} when registering the test.

Each registered test is executed and timed. The time is written to the gnuplot file. The number of times each test is executed is controlled by the parameters passed to \mbox{\hyperlink{group__Eina__Benchmark__Group_ga9732a7da5665e92d0afaf0367d2f6b85}{eina\+\_\+benchmark\+\_\+register()}}. 

References \mbox{\hyperlink{eina__alloca_8h_ae13861224cb6597c3171a910683cb5fc}{alloca()}}, \mbox{\hyperlink{group__Eina__Array__Group_gaf4b5844225b5359a617744210a5ed6ff}{eina\+\_\+array\+\_\+new()}}, \mbox{\hyperlink{group__Eina__Array__Group_ga97ac1fe353f4cd7a9762af4d4db7b9c4}{eina\+\_\+array\+\_\+push()}}, \mbox{\hyperlink{group__Eina__Counter__Group_ga0fc2b5ee268ade1d64e60d0fe41e7191}{eina\+\_\+counter\+\_\+dump()}}, \mbox{\hyperlink{group__Eina__Counter__Group_gabc8adceb04663f438d064cde35ba5d87}{eina\+\_\+counter\+\_\+free()}}, \mbox{\hyperlink{group__Eina__Counter__Group_ga51b43d4c8d06872b6bd1dcffffaa01e8}{eina\+\_\+counter\+\_\+new()}}, \mbox{\hyperlink{group__Eina__Counter__Group_ga13c8bbfa48271d1260ab40ffb065f831}{eina\+\_\+counter\+\_\+start()}}, \mbox{\hyperlink{group__Eina__Counter__Group_ga93daab9a42d94fc87bda3ea09759cbbd}{eina\+\_\+counter\+\_\+stop()}}, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__Inline__List__Group_ga65e496b9b16d527d23c1d735652b4e62}{EINA\+\_\+\+INLIST\+\_\+\+FOREACH}}, \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\+\_\+list\+\_\+append()}}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_gad476e89a04c3f1571e3628facd4319bb}{eina\+\_\+strbuf\+\_\+append()}}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga88d8da6589bad44714ad9e47aaa1992b}{eina\+\_\+strbuf\+\_\+free()}}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga13277ebcc07defa040d6e92f22774031}{eina\+\_\+strbuf\+\_\+new()}}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_gade7cf2d9653035e8362b85720df9214c}{eina\+\_\+strbuf\+\_\+replace\+\_\+all()}}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_gafd020a4f5483d73741c9d1b6d44b24d5}{eina\+\_\+strbuf\+\_\+string\+\_\+get()}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.

