Generally speaking, given a decision problem and a strategy to solve it, one way to measure it''s quality is the "regret"): the difference (or the ratio) between the payoff of the theoretically optimal strategy and the payoff of the strategy under consideration.

If the strategies are algorithms, then you can further refine the concept by including resource constraints (e.g. running in polynomial time, or running within X seconds).

In general, I don't think there is really a definition that fits well all cases in a non-trivial way: a clock optimizes keeping time, a rock optimizes laying around and occasionally falling, but we don't usually think of these things as agents trying to optimize an utility function.

Done