Challenge: Implementing Benchmarking
Swipe to start coding
You have definitions for two functions. Both functions return a copy of the original array with its elements squared. The first approach, the slower one, uses a for
loop to square each element individually, while the second approach leverages vectorization.
Your task is to perform a benchmark of both functions. To do this:
- Complete the definitions of two functions:
- The first, with
for
loop, should be namedsquare_array_slow
, and take a single parameterarray
; - The second, with vectorization, should be named
square_array_fast
, and take a single parameterarray
.
- The first, with
- Decorate both functions with the
timeit_decorator
and set itsnumber
parameter to100
.
Solução
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Awesome!
Completion rate improved to 7.69
Challenge: Implementing Benchmarking
Deslize para mostrar o menu
Swipe to start coding
You have definitions for two functions. Both functions return a copy of the original array with its elements squared. The first approach, the slower one, uses a for
loop to square each element individually, while the second approach leverages vectorization.
Your task is to perform a benchmark of both functions. To do this:
- Complete the definitions of two functions:
- The first, with
for
loop, should be namedsquare_array_slow
, and take a single parameterarray
; - The second, with vectorization, should be named
square_array_fast
, and take a single parameterarray
.
- The first, with
- Decorate both functions with the
timeit_decorator
and set itsnumber
parameter to100
.
Solução
Obrigado pelo seu feedback!
single