ruby profiling

20
Ruby profiling Fabio Perrella

Upload: fabio-perrella

Post on 15-Aug-2015

168 views

Category:

Technology


0 download

TRANSCRIPT

Ruby profilingFabio Perrella

Profiling

Profiling is a form of dynamic program analysis that measures, for example, the space (memory) or time complexity of a program, the usage of particular instructions, or the frequency and duration of function calls.

Wikipedia

PHP

Xdebug (extension)

KCacheGrind

SMTP Locaweb

- Lentidão na exportação de relatórios- Como melhorar a performance?

SMTP Locaweb

- Lentidão na exportação de relatórios- Como melhorar a performance?

Gem ruby-prof !

Tipos de medição

- wall time (tempo real decorrido entre 2 momentos)

- process time- cpu time- object allocations- memory usage- garbage collection time- garbage collections runs

Exemplo

Relatório tipo graph

Como entender o relatório

https://github.com/ruby-prof/ruby-prof/blob/master/examples/graph.txt

Relatório tipo stack

Caso de uso

- projeto Saas Smtp Panel- rspec --profile

Código com profile

Resultado do profiling

O teste com problema

O código

A correção

Processo iterativo

- rodar profiling- analisar relatório- corrigir problema- voltar ao 1o passo

Recomendações (Rails)

- criar um environment “profile”- ligar cache de classes (como em prod)- utilizar massa de dados considerável- adicionar no config.ru:

Relatório tipo stack

Dúvidas?