Can't you simply call this method with the parameters and count them?
java -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails TestFunc
Point 1
If you have GC calls during your method you will get wrong results. All GC calls are Stop The World calls for some phases of the algorithm, this meaning that your Threads are put on hold for that particular time. For how much it depends on the application that you are running, the heap you are giving to the JVM and the GC algorithm that you choose for the young and old generation. Note that calls to young generation are way cheaper then those in the old generation.
Point 2
Benchmarking in Java is complicated, mainly because of the JIT. You should use a library for your tests (if you can). One very good is JMH. If you can't use one, then let the jvm heat up a bit before running the actual benchmark, like 10000 times running the same method then measuring is usually the recommended.