\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 \mbox{\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$ \mbox{\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}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Eina__Benchmark__Group_gac5c05887f0ad72bfb28b53e6fde49ce2}{Eina\+\_\+\+Benchmark}} $\ast$ \mbox{\hyperlink{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}{eina\+\_\+benchmark\+\_\+new}} (const char $\ast$name, const char $\ast$run)
\begin{DoxyCompactList}\small\item\em Creates a new array. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__Eina__Benchmark__Group_gac8f2877d714ab6fe90d0fa08f87567c5}{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_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Eina__Benchmark__Group_gacd15985f85c6cbfe21f7c1c1902dd2b3}{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__Array__Group_ga2a57284ee83a7e767485b7ae2f5df86c}{Eina\+\_\+\+Array}} $\ast$ \mbox{\hyperlink{group__Eina__Benchmark__Group_ga56b67e26be3cf49cccffa4c148148eaf}{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_gafee4bfc0e509b6ffed6598edf6f4b3de}{eina\+\_\+init()}} and later shut down with \mbox{\hyperlink{group__Eina__Main__Group_ga2c8b4020427108a30c44707af22c99d3}{eina\+\_\+shutdown()}}. A benchmark is created with \mbox{\hyperlink{group__Eina__Benchmark__Group_gacd3e2dcff8292721754714125572936a}{eina\+\_\+benchmark\+\_\+new()}} and freed with \mbox{\hyperlink{group__Eina__Benchmark__Group_gac8f2877d714ab6fe90d0fa08f87567c5}{eina\+\_\+benchmark\+\_\+free()}}.

\mbox{\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.

\mbox{\hyperlink{group__Eina__Benchmark__Group_ga56b67e26be3cf49cccffa4c148148eaf}{eina\+\_\+benchmark\+\_\+run()}} runs all the tests registered with \mbox{\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 \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_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}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_new()}{eina\_benchmark\_new()}}
{\footnotesize\ttfamily \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_ga56b67e26be3cf49cccffa4c148148eaf}{eina\+\_\+benchmark\+\_\+run()}} will create.

When the new module is not needed anymore, use \mbox{\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}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_free()}{eina\_benchmark\_free()}}
{\footnotesize\ttfamily 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 eina\+\_\+array\+\_\+free(), EINA\+\_\+\+ARRAY\+\_\+\+ITER\+\_\+\+NEXT, eina\+\_\+inlist\+\_\+remove(), and EINA\+\_\+\+LIST\+\_\+\+FREE.

\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}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_register()}{eina\_benchmark\_register()}}
{\footnotesize\ttfamily \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_ga56b67e26be3cf49cccffa4c148148eaf}{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 EINA\+\_\+\+FALSE, eina\+\_\+inlist\+\_\+append(), EINA\+\_\+\+INLIST\+\_\+\+GET, and EINA\+\_\+\+TRUE.

\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}}
\doxysubsubsection{\texorpdfstring{eina\_benchmark\_run()}{eina\_benchmark\_run()}}
{\footnotesize\ttfamily \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_gacd15985f85c6cbfe21f7c1c1902dd2b3}{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_gacd3e2dcff8292721754714125572936a}{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_gacd15985f85c6cbfe21f7c1c1902dd2b3}{eina\+\_\+benchmark\+\_\+register()}}. 

References alloca(), eina\+\_\+array\+\_\+new(), eina\+\_\+array\+\_\+push(), eina\+\_\+counter\+\_\+dump(), eina\+\_\+counter\+\_\+free(), eina\+\_\+counter\+\_\+new(), eina\+\_\+counter\+\_\+start(), eina\+\_\+counter\+\_\+stop(), EINA\+\_\+\+FALSE, EINA\+\_\+\+INLIST\+\_\+\+FOREACH, eina\+\_\+list\+\_\+append(), eina\+\_\+strbuf\+\_\+append(), eina\+\_\+strbuf\+\_\+free(), eina\+\_\+strbuf\+\_\+new(), eina\+\_\+strbuf\+\_\+replace\+\_\+all(), eina\+\_\+strbuf\+\_\+string\+\_\+get(), and EINA\+\_\+\+TRUE.

