D
D
Dmitry Korolev2017-08-18 15:17:19
C++ / C#
Dmitry Korolev, 2017-08-18 15:17:19

How to find out how long the called function will be executed?

You need to find out how long the called function will be executed.
This function can process one file, it can process several files, it can process an entire directory.
How to show the progress of its implementation?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman, 2017-08-18
@yarosroman

Alternatively, put the function in a separate thread, and update the progress through the callback.

L
LiptonOlolo, 2017-08-18
@LiptonOlolo

Stopwatch s = new Stopwatch();
s.Start();
//Work
s.Stop();
Console.WriteLine(s.Elapsed);

D
Daniil Basmanov, 2017-08-18
@BasmanovDaniil

You create a zero counter, after processing each file you increment it and count the ratio of processed files to the total number. If only a function knows about the number of processed / unprocessed files, then you can throw a callback into it, which will give two numbers each time the counter state changes, and you will somehow display these numbers outside. Or remake the function so that it takes a list of files as input, then only the number of processed files will need to be returned outside. Or display progress on the screen in the function itself, as you wish.
If we talk about a specific way to display a progress bar on the screen, then in the editor you can use EditorUtility.DisplayProgressBar , and in runtime Slider .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question