セクション 1. 章 4
single
Challenge: Implementing Benchmarking
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
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
forloop, 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_decoratorand set itsnumberparameter to100.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 4
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください