Question: The path to the folder and the format come to the input of the batch file 
file(for example, txt) (as parameters of a batch file). 
The folder must contain different files. 
If such folder does not exist, then write “This folder does not exist” and 
terminate the program. 
If such a folder exists, then find everything in it and in its subfolders 
files of the specified extension for which it is installed 
archive attribute. Output the number of such files in 
console

**[Edit /]**

This is what I have:

```
@echo off
if not exist %1 (echo "This folder does not exist" && pause && exit /B )
set /a count=0
for %%i in (dir %1\*.%2 /A:A /S ) do ( set /a count+=1 )
Echo in the folder %1, found %count% files with extension %2 and attribute 
Archive
pause

```

The final count is incorrect
[![enter image description here](https://i.stack.imgur.com/izyaN.png)](https://i.stack.imgur.com/izyaN.png)

Answer: 
You solution is just fine.

A less expressive way would be to wrap your code to be timed in a lambda.

```
public void timeCode(Runnable code) {
    ...
    try {
        code.run();
    } catch ...
    }
    ...
}

timeCode(() -> { ...code to time... });

```

You would probably like to catch the checked exceptions and pass them to some runtime exception or whatever.
You method is great as-is. We use something similar professionally but written in C#.

One thing that I would potentially add, is proper logging support, so that you can toggle those performance numbers, or have them at a debug or info level.

Additional improvements that I would be considering, is creating some static application state, (abusing thread locals) so that you can nest these sections, and have summary breakdowns.

See <https://github.com/aikar/minecraft-timings> for a library that does this for minecraft modding (written in java).