Python Testing and Project Tools
Find where the report spends its time
BOTIE
Examples, experiments and workspace controls
Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.
Try your own inputs
Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.
Context for this challenge
Multiply calls by self_ms_per_call for each row, find the largest total, and return that complete profile row. For the first example, reading costs 200 ms, formatting 100 ms and validation 8 ms. If totals tie, keep the first tied row.
The first suspect is the function with the most calls, but call count alone does not show total cost.
Read the calls and self_ms_per_call columns. Multiply them to obtain total self milliseconds. Find the largest cost position, then retrieve that row from the original profile.
Examples and results
- Recorded report operations and their costs
- operation
- Read source
- calls
- 40
- self_ms_per_call
- 5
- operation
- Format report
- calls
- 1000
- self_ms_per_call
- 0.1
- operation
- Validate records
- calls
- 40
- self_ms_per_call
- 0.2
operation calls self_ms_per_call Read source 40 5 Format report 1000 0.1 Validate records 40 0.2 - Required result
- operation
- Read source
- calls
- 40
- self_ms_per_call
- 5
- Recorded report operations and their costs
- operation
- Read source
- calls
- 4
- self_ms_per_call
- 5
- operation
- Format report
- calls
- 200
- self_ms_per_call
- 0.1
operation calls self_ms_per_call Read source 4 5 Format report 200 0.1 - Required result
- operation
- Read source
- calls
- 4
- self_ms_per_call
- 5
Try a fresh construction
This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.
Stuck? Inspect a worked construction
The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.
Assumptions and test precision
These measurements are invented and supplied. The blocks calculate estimates from them; they do not time Python. A real optimization also needs fresh measurements and unchanged behavior tests. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.
Few expensive calls outweigh many quick ones
This check uses the pieces from “Calculate the cost of each operation”.
BOTIE
- Recorded report operations and their costs
- operation
- Format report
- calls
- 1000
- self_ms_per_call
- 0.01
- operation
- Read source
- calls
- 2
- self_ms_per_call
- 40
operation calls self_ms_per_call Format report 1000 0.01 Read source 2 40
Saving your prediction runs your current construction on these inputs and checks the earlier examples too.
Build a construction in the workspace above first. This case will test those pieces.
Which measurement would show that a proposed repair helped the workload you care about?
Measure the changed program again before choosing the next optimization.
These measurements are invented and supplied. The blocks calculate estimates from them; they do not time Python. A real optimization also needs fresh measurements and unchanged behavior tests.