Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Implementing Benchmarking | Understanding and Measuring Performance
Optimization Techniques in Python
セクション 1.  4
single

single

bookChallenge: 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:

  1. Complete the definitions of two functions:
    • The first, with for loop, should be named square_array_slow, and take a single parameter array;
    • The second, with vectorization, should be named square_array_fast, and take a single parameter array.
  2. Decorate both functions with the timeit_decorator and set its number parameter to 100.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  4
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt