I have a function func[x], which is rather slow to evaluate. It gets called (multiple times) inside other expressions; I'd like to know how many times it gets called (without actually evaluating the expression). (This is so I can estimate how long it will take.) For example, I'd like to make a function that would take
3x*Hold[func]+Hold[func]*Hold[func] and return 3, because func would get called three times if I ran the code (with
I was thinking that string matching would be the way to go, namely come up with a list of symbols in
3x*Hold[func]+Hold[func]*Hold[func], convert that into a list of strings, and then count the number of times
func appears, but I haven't figured out a way to do the first two steps.
To be clear, I know that I'm always calling my function in expressions like the above, in which it's going to be evaluated once, so I only need to count the number of times "func" appears.
Help/ideas would be appreciated.