Profiling#
In rbx, profiling is the process of measuring how long your solutions take and turning those measurements into a time limit for the problem.
Picking that number by hand is guessing. Too generous and the quadratic solution you wrote the problem to reject sneaks through; too tight and a correct solution in Python fails on a judge whose machine is slower than yours. And it is not one number: the same problem deserves a different answer on your laptop and on each judge it ships to.
rbx measures instead. You run one command, it times your solutions, applies the rules your environment configures, and writes the result to a limits profile — a file you can keep one of per judge you ship to.
Motivational problem#
Every page in this section teaches against one problem, so you never have to re-orient. It asks
for the number of pairs of values in a list that add up to K, and it is solved three ways:
solutions:
- path: sols/main.cpp # (1)!
outcome: ac
- path: sols/main.py # (2)!
outcome: ac
- path: sols/quadratic.cpp # (3)!
outcome: tle
- Sorts, then walks the list from both ends:
O(n log n). - The same idea in Python, and several times slower for it. Two accepted solutions in different languages is what makes a per-language limit mean anything.
- Compares every pair:
O(n²). This is the solution the time limit exists to reject, and saying so withoutcome: tleis what lets rbx check the limit against it.
Notice that nothing here mentions Java, and no solution is written in it. That is deliberate, and Language groups is about what rbx does with it.
Estimating a limit#
Run rbx time:
It builds the problem, times the accepted solutions, asks you how to bucket the languages, and then checks the limit it arrived at against the solutions you said were too slow:
Don't worry about following all of that yet
That is the whole mechanism at once, and it is not meant to be readable on a first pass. Every part of it — the prompt, the bucketing screen, the arithmetic behind the numbers, and the check at the end — gets a page of its own below. Read this as what the command does, and come back once you have met the pieces.
The table at the end is the answer. cpp gets 100 ms from its own measurements, py gets
200 ms from its own, and java — which nothing solves — gets ×2.0 of cpp, because the
environment says an unsolved language should follow C++ rather than fall back to the base
limit.
Using the limit#
The estimate is written to .limits/local.yml, and local is the profile rbx runs with
when you do not ask for another:
For a judge with hardware of its own, estimate into a profile named after it, and ask for that profile by name:
- A packager looks for the profile named after it, so this is the one
rbx package bocawill use. See Profiles and packaging.
Where to go next#
-
What a profile is, and every command that reads one.
-
rbx timein full: strategies, the estimation cap, and the upper-bound check. -
The ratios, the formula alternative, and wall time.
-
Giving each language a limit that suits it.
-
Measuring on the judge park instead of your machine.