Accounting and optimization of work and consumption of resources