\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\+R\+K}(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 
\hypertarget{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{typedef struct \+\_\+\+Eina\+\_\+\+Benchmark \hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}}\label{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}

\begin{DoxyCompactList}\small\item\em Type for a benchmark. \end{DoxyCompactList}\item 
\hypertarget{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{typedef void($\ast$ \hyperlink{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}{Eina\+\_\+\+Benchmark\+\_\+\+Specimens} )(int request)}\label{group__Eina__Benchmark__Group_gadf67e817134419261b3c2beb5f8f6494}

\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}
\hypertarget{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}{\index{Benchmark@{Benchmark}!E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+R\+K@{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+R\+K}}
\index{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+R\+K@{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+R\+K}!Benchmark@{Benchmark}}
\subsubsection[{E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+R\+K}]{\setlength{\rightskip}{0pt plus 5cm}\#define E\+I\+N\+A\+\_\+\+B\+E\+N\+C\+H\+M\+A\+R\+K(
\begin{DoxyParamCaption}
\item[{}]{function}
\end{DoxyParamCaption}
)~(({\bf Eina\+\_\+\+Benchmark\+\_\+\+Specimens})function)}}\label{group__Eina__Benchmark__Group_ga64c3594df1ad868efe1454c34e3e1c37}


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}
\hypertarget{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}{\index{Benchmark@{Benchmark}!eina\+\_\+benchmark\+\_\+new@{eina\+\_\+benchmark\+\_\+new}}
\index{eina\+\_\+benchmark\+\_\+new@{eina\+\_\+benchmark\+\_\+new}!Benchmark@{Benchmark}}
\subsubsection[{eina\+\_\+benchmark\+\_\+new}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Benchmark}$\ast$ eina\+\_\+benchmark\+\_\+new (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{name, }
\item[{const char $\ast$}]{run}
\end{DoxyParamCaption}
)}}\label{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}


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\+L\+L} on failure, non {\ttfamily N\+U\+L\+L} 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\+L\+L} 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. \hypertarget{group__Eina__Benchmark__Group_gac8f2877d714ab6fe90d0fa08f87567c5}{\index{Benchmark@{Benchmark}!eina\+\_\+benchmark\+\_\+free@{eina\+\_\+benchmark\+\_\+free}}
\index{eina\+\_\+benchmark\+\_\+free@{eina\+\_\+benchmark\+\_\+free}!Benchmark@{Benchmark}}
\subsubsection[{eina\+\_\+benchmark\+\_\+free}]{\setlength{\rightskip}{0pt plus 5cm}void eina\+\_\+benchmark\+\_\+free (
\begin{DoxyParamCaption}
\item[{{\bf Eina\+\_\+\+Benchmark} $\ast$}]{bench}
\end{DoxyParamCaption}
)}}\label{group__Eina__Benchmark__Group_gac8f2877d714ab6fe90d0fa08f87567c5}


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\+L\+L}, this function returns immediately. 

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

\hypertarget{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}{\index{Benchmark@{Benchmark}!eina\+\_\+benchmark\+\_\+register@{eina\+\_\+benchmark\+\_\+register}}
\index{eina\+\_\+benchmark\+\_\+register@{eina\+\_\+benchmark\+\_\+register}!Benchmark@{Benchmark}}
\subsubsection[{eina\+\_\+benchmark\+\_\+register}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Bool} eina\+\_\+benchmark\+\_\+register (
\begin{DoxyParamCaption}
\item[{{\bf Eina\+\_\+\+Benchmark} $\ast$}]{bench, }
\item[{const char $\ast$}]{name, }
\item[{{\bf Eina\+\_\+\+Benchmark\+\_\+\+Specimens}}]{bench\+\_\+cb, }
\item[{int}]{count\+\_\+start, }
\item[{int}]{count\+\_\+end, }
\item[{int}]{count\+\_\+step}
\end{DoxyParamCaption}
)}}\label{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}


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\+S\+E} on failure, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+U\+E} 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\+L\+L}, this function returns immediately. This function returns \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E} on failure, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+U\+E} otherwise. 

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

\hypertarget{group__Eina__Benchmark__Group_ga56b67e26be3cf49cccffa4c148148eaf}{\index{Benchmark@{Benchmark}!eina\+\_\+benchmark\+\_\+run@{eina\+\_\+benchmark\+\_\+run}}
\index{eina\+\_\+benchmark\+\_\+run@{eina\+\_\+benchmark\+\_\+run}!Benchmark@{Benchmark}}
\subsubsection[{eina\+\_\+benchmark\+\_\+run}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Array}$\ast$ eina\+\_\+benchmark\+\_\+run (
\begin{DoxyParamCaption}
\item[{{\bf Eina\+\_\+\+Benchmark} $\ast$}]{bench}
\end{DoxyParamCaption}
)}}\label{group__Eina__Benchmark__Group_ga56b67e26be3cf49cccffa4c148148eaf}


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}
1 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\+L\+L}, this functions returns {\ttfamily N\+U\+L\+L} 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\+S\+E, E\+I\+N\+A\+\_\+\+I\+N\+L\+I\+S\+T\+\_\+\+F\+O\+R\+E\+A\+C\+H, eina\+\_\+list\+\_\+append(), and E\+I\+N\+A\+\_\+\+T\+R\+U\+E.

