Libraries and individual program components are provided with a common
interface and a number of alternative implementations (e.g. hash table,
tree, compressed) which can be selected. The component is instrumented to
measure a cost of each of its alternative implementations, both
independent of and in the context of the interaction of that component
with other components of the computer program. Based on measured cost,
the desired implementation is chosen for the component by an external
controller that is generic to the computer program or by an application
program that interfaces with the library or component.