# How to count the number of operations performed during a calculation?

**URL:** <https://community.wolfram.com/t/how-to-count-the-number-of-operations-performed-during-a-calculation/337>\
**Category:** Questions\
**Tags:** ruliology, computer-science, mathematica, optimization, numerical-computation\
**Created:** [August 6, 2013, 2:25pm UTC](https://community.wolfram.com/t/how-to-count-the-number-of-operations-performed-during-a-calculation/337 "2013-08-06T14:25:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrorsino](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rrorsino](https://community.wolfram.com/u/rrorsino)\
**Post date:** [August 6, 2013, 2:25pm UTC](https://community.wolfram.com/t/how-to-count-the-number-of-operations-performed-during-a-calculation/337/1 "2013-08-06T14:25:23Z")

</div>

I need to know how can I count the number of operations performed during a calculation of a CompoundExpression.

In some of these expressions there are Dot products between matrices and I want to count how many additions a multiplications are performed in each of these calculations.

In other words, I need a functions that does the same as the function cost of Maple ([cost - Maple Help](http://www.maplesoft.com/support/help/Maple/view.aspx?path=codegen/cost))

For instance, I want to know how many additions and multiplications are performed in the execution of the following function:

```auto
LinearSolve[Dot[{{1, 2}, {3, 4}}, {{5, 6}, {3, 4}}], {5, 6}]

```

How can I do it?

---

<div class="post-metadata">

**Author:** ![shenghuiy](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/shenghuiy/32/36073_2.png) [@shenghuiy](https://community.wolfram.com/u/shenghuiy)\
**Post date:** [August 7, 2013, 2:17am UTC](https://community.wolfram.com/t/how-to-count-the-number-of-operations-performed-during-a-calculation/337/2 "2013-08-07T02:17:21Z")

</div>

Hey Renato,

I am not particulary sure about this case. In general you can use [Trace](http://reference.wolfram.com/mathematica/ref/Trace.html) to get the inforamtion about internal steps. For the Mathematica numeric solvers such as NDSolve and FindMinimum, they have a [StepMonitor](http://reference.wolfram.com/mathematica/ref/StepMonitor.html) option, which extracts very detailed internal steps for you.
