

% add the PATH to retrieve cls and sty beamer styles files
\makeatletter
\providecommand*{\input@path}{}
\edef\input@path{{../../support/beamer/}\input@path}% prepend
\makeatother

% \documentclass{pharoslides}
% \documentclass[aspectratio=169]{pharoslides} % format 16/9
\documentclass[withvideo]{pharoslides} % format 16/9 + incrustation video

\graphicspath{{./figures/}{../}{../../support/beamer/imgs/}}

%Information to be included in the title page:
\title{Benchmarking in Pharo}
\subtitle{}
\author{Damien Cassou, Stéphane Ducasse and Luc Fabresse}
\institute{http://stephane.ducasse.free.fr}
\date{}
\slidesid{W5S09}

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\frametitle{Common Wisdom}

If you did not profile your code you may have 40-50\% speed up waiting for you.
\end{frame}



\begin{frame}[fragile]

\frametitle{Measuring Execution Speed}

We create an expression and use \code{{[} expression {]} timeToRun}

\begin{listing}{}
[ 1000 factorial ] timeToRun
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Comparing Two Executions}

Is  \code{select:}, then \code{collect:} slower than \code{select:thenCollect:}?
\end{frame}



\begin{frame}[fragile]

\frametitle{timeToRun example}

\begin{listing}{}
| coll |
coll := #(1 2 3 4 5 6 7 8 9 10) asOrderedCollection.
[ 1000000 timesRepeat: [ 
		(coll select: [ :each | each > 5]) collect: [ :i | i * i ]]
	] timeToRun
>  "0:00:00:00.517"
\end{listing}

\begin{listing}{}
| coll |
coll := #(1 2 3 4 5 6 7 8 9 10) asOrderedCollection.
[ 1000000 timesRepeat: [ 
		coll 
			select: [ :each | each > 5]
			thenCollect: [ :i | i * i ]]
		] timeToRun 
> "0:00:00:00.362"
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{bench}

\begin{itemize}
\item Returns how many times the code can get executed in 5 seconds
\item Answer a string with meaningful description
\end{itemize}

\begin{listing}{}
[ 1000 factorial ] bench 
> '610.234 per second' 
\end{listing}

The higher the better!

\code{{[} 1234 factorial {]} benchFor: 2 seconds}
\end{frame}



\begin{frame}[fragile]

\frametitle{Time Profiler}

\begin{itemize}
\item \code{TimeProfiler}: a sampling-based code profiler
\item At regular interval, take information from the execution stack
\end{itemize}

\begin{listing}{}
TimeProfiler 
  spyOn: [ 20 timesRepeat: [ 
            Transcript show: 1000 factorial printString ] ]
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Time Profiler}


\begin{center}
\includegraphics[width=0.9\textwidth]{figures/TimeProfiler.png}\end{center}

\end{frame}



\begin{frame}[fragile]

\frametitle{Summary}

\begin{itemize}
\item \code{{[} anExpression {]} timeToRun}
\item \code{{[} anExpression {]} bench}
\item \code{TimeProfiler spyOn: {[} anExpression {]}}
\item Check \textit{Profiling Applications} Chapter in \textbf{Deep into Pharo} (at \url{http://books.pharo.org})
\end{itemize}
\end{frame}




% \setlength{\textwidth}{\originaltextwidth}
\setbeamertemplate{background canvas}{\insertBorderForHandout}

\begin{frame}[plain]

\begin{minipage}{\originaltextwidth}
\centering
\large


\vspace{2em}

A course by

\vspace{1em}

\hspace{-20px}\includegraphics[height=32px]{inriaLogo}\hspace{3em}\raisebox{7px}{and}\hspace{3em}\raisebox{-6px}{\includegraphics[height=30px]{logoutop}}

\vspace{2em}

in collaboration with

\vspace{1em}

\includegraphics[height=40px]{unisciellogo}\hskip 1.5em%
\raisebox{5px}{\includegraphics[height=30px]{unitlogo}}\hskip 2em%
\raisebox{8px}{\includegraphics[height=24px]{univLilleLogo}}\hskip 2em%
\raisebox{3px}{\includegraphics[height=29px]{logo-IMT}}\hskip 2em%
\raisebox{1px}{\includegraphics[height=32px]{minesDouaiLogo}}

\vspace{2.5em}

\includegraphics[width=50px]{by-nc-nd} \tiny \hskip 0.5em \raisebox{5px}{Inria 2016}

\medskip

\tiny
Except where otherwise noted, this work is licensed under CC BY-NC-ND 3.0 France

\url{https://creativecommons.org/licenses/by-nc-nd/3.0/fr/} 

\end{minipage}
\end{frame}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
