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


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


\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+RK}(function)~((\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens})function)
\begin{DoxyCompactList}\small\item\em cast to an \hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}\label{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}} 
typedef struct \+\_\+\+Eina\+\_\+\+Benchmark \hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{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$ \hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{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}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark} $\ast$ \hyperlink{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}{eina\+\_\+benchmark\+\_\+new} (const char $\ast$name, const char $\ast$run)
\begin{DoxyCompactList}\small\item\em Create a new array. \end{DoxyCompactList}\item 
void \hyperlink{group__Eina__Benchmark__Group_gac8f2877d714ab6fe90d0fa08f87567c5}{eina\+\_\+benchmark\+\_\+free} (\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark} $\ast$bench)
\begin{DoxyCompactList}\small\item\em Free a benchmark object. \end{DoxyCompactList}\item 
\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}{eina\+\_\+benchmark\+\_\+register} (\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark} $\ast$bench, const char $\ast$name, \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 Add a test to a benchmark. \end{DoxyCompactList}\item 
\hyperlink{group__Eina__Array__Group_ga2a57284ee83a7e767485b7ae2f5df86c}{Eina\+\_\+\+Array} $\ast$ \hyperlink{group__Eina__Benchmark__Group_ga56b67e26be3cf49cccffa4c148148eaf}{eina\+\_\+benchmark\+\_\+run} (\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark} $\ast$bench)
\begin{DoxyCompactList}\small\item\em Run the benchmark tests that have been registered. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
These functions allow you to add benchmark framework in a project for timing critical part and detect 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 \hyperlink{group__Eina__Main__Group_gabf448ada5bc81a07342b66c6f818ee5e}{eina\+\_\+init()} and later shut down with \hyperlink{group__Eina__Main__Group_ga6741fcaba116e31e96ce14dcfa03f568}{eina\+\_\+shutdown()}. A benchmark is created with \hyperlink{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}{eina\+\_\+benchmark\+\_\+new()} and freed with \hyperlink{group__Eina__Benchmark__Group_gac8f2877d714ab6fe90d0fa08f87567c5}{eina\+\_\+benchmark\+\_\+free()}.

\hyperlink{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}{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.

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

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

\subsection{Macro Definition Documentation}
\mbox{\Hypertarget{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}\label{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}} 
\index{Benchmark@{Benchmark}!E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+RK@{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+RK}}
\index{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+RK@{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+RK}!Benchmark@{Benchmark}}
\subsubsection{\texorpdfstring{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+RK}{EINA\_BENCHMARK}}
{\footnotesize\ttfamily \#define E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+RK(\begin{DoxyParamCaption}\item[{}]{function }\end{DoxyParamCaption})~((\hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens})function)}



cast to an \hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens}. 


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

\subsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}\label{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}} 
\index{Benchmark@{Benchmark}!eina\+\_\+benchmark\+\_\+new@{eina\+\_\+benchmark\+\_\+new}}
\index{eina\+\_\+benchmark\+\_\+new@{eina\+\_\+benchmark\+\_\+new}!Benchmark@{Benchmark}}
\subsubsection{\texorpdfstring{eina\+\_\+benchmark\+\_\+new()}{eina\_benchmark\_new()}}
{\footnotesize\ttfamily \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})}



Create a new array. 


\begin{DoxyParams}{Parameters}
{\em name} & The name of the benchmark. \\
\hline
{\em run} & The name of the run. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily N\+U\+LL} on failure, non {\ttfamily N\+U\+LL} otherwise.
\end{DoxyReturn}
This function creates a new benchmark. {\ttfamily name} and {\ttfamily run} are used to name the gnuplot file that \hyperlink{group__Eina__Benchmark__Group_ga56b67e26be3cf49cccffa4c148148eaf}{eina\+\_\+benchmark\+\_\+run()} will create.

This function return a valid benchmark on success, or {\ttfamily N\+U\+LL} if memory allocation fails.

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



Free a benchmark object. 


\begin{DoxyParams}{Parameters}
{\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 N\+U\+LL}, this function returns immediately. 

References eina\+\_\+array\+\_\+free(), E\+I\+N\+A\+\_\+\+A\+R\+R\+A\+Y\+\_\+\+I\+T\+E\+R\+\_\+\+N\+E\+XT, eina\+\_\+inlist\+\_\+remove(), and E\+I\+N\+A\+\_\+\+L\+I\+S\+T\+\_\+\+F\+R\+EE.

\mbox{\Hypertarget{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}\label{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}} 
\index{Benchmark@{Benchmark}!eina\+\_\+benchmark\+\_\+register@{eina\+\_\+benchmark\+\_\+register}}
\index{eina\+\_\+benchmark\+\_\+register@{eina\+\_\+benchmark\+\_\+register}!Benchmark@{Benchmark}}
\subsubsection{\texorpdfstring{eina\+\_\+benchmark\+\_\+register()}{eina\_benchmark\_register()}}
{\footnotesize\ttfamily \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} eina\+\_\+benchmark\+\_\+register (\begin{DoxyParamCaption}\item[{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark} $\ast$}]{bench,  }\item[{const char $\ast$}]{name,  }\item[{\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})}



Add a test to a benchmark. 


\begin{DoxyParams}{Parameters}
{\em bench} & The benchmark. \\
\hline
{\em name} & The name of the test. \\
\hline
{\em bench\+\_\+cb} & The test function to be called. \\
\hline
{\em count\+\_\+start} & The start data to be passed to {\ttfamily bench\+\_\+cb}. \\
\hline
{\em count\+\_\+end} & The end data to be passed to {\ttfamily bench\+\_\+cb}. \\
\hline
{\em count\+\_\+step} & The step data to be passed to {\ttfamily bench\+\_\+cb}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{E\+I\+N\+A\+\_\+\+F\+A\+L\+SE} on failure, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+UE} 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 amount of time. {\ttfamily count\+\_\+start}, {\ttfamily count\+\_\+end} and {\ttfamily count\+\_\+step} define a loop with a step increment. The integer that is increasing by {\ttfamily count\+\_\+step} from {\ttfamily count\+\_\+start} to {\ttfamily count\+\_\+end} is passed to {\ttfamily bench\+\_\+cb} when \hyperlink{group__Eina__Benchmark__Group_ga56b67e26be3cf49cccffa4c148148eaf}{eina\+\_\+benchmark\+\_\+run()} is called.

If {\ttfamily bench} is {\ttfamily N\+U\+LL}, this function returns immediately. This function returns \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{E\+I\+N\+A\+\_\+\+F\+A\+L\+SE} on failure, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+UE} otherwise. 

References E\+I\+N\+A\+\_\+\+F\+A\+L\+SE, eina\+\_\+inlist\+\_\+append(), E\+I\+N\+A\+\_\+\+I\+N\+L\+I\+S\+T\+\_\+\+G\+ET, and E\+I\+N\+A\+\_\+\+T\+R\+UE.

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



Run the benchmark tests that have been registered. 


\begin{DoxyParams}{Parameters}
{\em bench} & The benchmark. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The list of names of the test files.
\end{DoxyReturn}
This function runs all the tests that as been registered with \hyperlink{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}{eina\+\_\+benchmark\+\_\+register()} and save the result in a gnuplot file. The name of the file has the following format\+:


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


where \mbox{[}name\mbox{]} and \mbox{[}run\mbox{]} are the values passed to \hyperlink{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}{eina\+\_\+benchmark\+\_\+new()}.

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 \hyperlink{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}{eina\+\_\+benchmark\+\_\+register()}.

If {\ttfamily bench} is {\ttfamily N\+U\+LL}, this functions returns {\ttfamily N\+U\+LL} immediately. Otherwise, it returns the list of the names of each test. 

References alloca(), eina\+\_\+array\+\_\+new(), eina\+\_\+array\+\_\+push(), eina\+\_\+counter\+\_\+dump(), eina\+\_\+counter\+\_\+free(), eina\+\_\+counter\+\_\+new(), eina\+\_\+counter\+\_\+start(), eina\+\_\+counter\+\_\+stop(), E\+I\+N\+A\+\_\+\+F\+A\+L\+SE, E\+I\+N\+A\+\_\+\+I\+N\+L\+I\+S\+T\+\_\+\+F\+O\+R\+E\+A\+CH, eina\+\_\+list\+\_\+append(), and E\+I\+N\+A\+\_\+\+T\+R\+UE.

