Hi,
I can’t seem to find any info in the Wiki, or on the MBS website. Is there a way to return a set time of completion for copying an item from X to Y in Xojo?
Thanks
Hi,
I can’t seem to find any info in the Wiki, or on the MBS website. Is there a way to return a set time of completion for copying an item from X to Y in Xojo?
Thanks
As in the regular copy file box and ProgressBar in Windows or Linux ?
Yep, i wanted to report back an est time of completion to a label.text on an app. Maybe have it on a timer doing an update every 10 seconds
I am trying to do this om mac
In know the speed of which the data is beeing written, and how much data is left to write.
E.g 32 mb a second / 4000mb left
I was wondering if i could use that for a time est?
[quote=108030:@Jay maxted]In know the speed of which the data is beeing written, and how much data is left to write.
E.g 32 mb a second / 4000mb left
I was wondering if i could use that for a time est?[/quote]
As you may have noticed the estimated completion time in big copy operations is usually far from being very precise. You could very well use that data to provide a progressbar that shows the user something is working. This should work for a simple CopyFileTo.
If you wanted a more precise progress indicator, then use binary streams to read the source and write the destination, and employ length and position to assert progress.
Can i not do throughput / whats left * 60 (seconds) ?
Sure. You must know, however, that read/write operations are affected by the system housekeeping, such as buffer flush, memory paging, indexing and who know what the system is doing. So if at a given time you measure performances and extrapolate, the actual time to completion will probably be different.
If you look at how Mac OS X conducts copy and informs the user, however, you will notice that the report is monitored throughout the operation, with often a changing display of the time to completion. For very big amounts of data, it often starts by showing preposterous time such as “one day” and progressively goes down to more tolerable figures, and at the end shows seconds elapsing. This can be only possible by monitoring real time.
Displaying a prospective time and completing early is usually not an issue, as what is important most of the time is to show the user data while a long operation is done to prevent him from feeling the computer is stuck or too slow. That is what I usually do.
Ok ill give it ago. My throughput speed is real time. The total size is fixed.
Why not report it as a percentage which takes disk speed out of the equation. You seem to know the total size and how much you have output so far so go with that to get your percentage competed or percentage left to complete, whichever you prefer.
Hey Harrie,
I already show a percentage. I will be backing up 300 to 400 gb at a time, an est on how long its going to take is better than a percent
Ive seen this here https://forum.xojo.com/12208-calculating-time-remaining/0
Does anyone think that @Greg O’Lone example would work for me?
[quote]Greg O May 23 Xojo Inc Jacksonville, FL Edited 6 weeks ago by Greg O’Lone
My 2 cents:
Record the start time when the process starts. I do this by setting a property on the window:
StartTime = ticks
I also suggest keeping an array of calculated times. If something causes your app to slow down, this will auto compensate:
TotalSecondsCalcs() as Integer
You’ll need a method for only averaging the most recent calculations:
Private Function Avg(numbers() as Integer, count as integer) As Integer
dim tot as integer
dim c as integer = min(numbers.ubound,count - 1)
for i as integer = 0 to c
tot = tot + numbers(i)
next i
return tot/(c+1)
End Function
Then call this method to calculate the number of seconds remaining.
[code]Private Function UpdateTimeRemaining(percentageComplete as Integer) As Integer
//What time is it now
dim currentTime as integer = ticks / 60
//How many seconds have elapsed
dim deltaSeconds as integer = currentTime - StartTime
//Based on the percentage complete, how many seconds will the whole process take
dim totalSeconds as integer = deltaSeconds / (percentageComplete/100)
//Add this value to the array
TotalSecondsCalcs.Insert 0,totalSeconds
//Get an average of the last 10 totals
dim averageTotal as integer = avg(totalSecondscalcs,10)
//Return the number of seconds we THINK it’s going to be
dim secondsRemaining as integer = averageTotal - deltaSeconds
return max(secondsRemaining,0)
End Function[/code][/quote]
[quote=108170:@Jay maxted]Ive seen this here https://forum.xojo.com/12208-calculating-time-remaining/0
Does anyone think that @Greg O’Lone example would work for me?[/quote]
If you can get a value for PercentageComplete, it can work. As far as I know, though, a simple CopyFileTo does not provide such information.
I have a copy complete. I now the exact Percent Done as my app tells me how much coppied to how much to be copied.
E.g.
Current copied: 1200MB of 4000Mb
1200/4000*100 = 30%
Are you able to help with some of the steps at all?
I do not get what he means by this:
Record the start time when the process starts. I do this by setting a property on the window:
StartTime = ticks
I also suggest keeping an array of calculated times. If something causes your app to slow down, this will auto compensate:
TotalSecondsCalcs() as Integer
[quote=108179:@Jay maxted]Are you able to help with some of the steps at all?
I do not get what he means by this:
Record the start time when the process starts. I do this by setting a property on the window:
StartTime = ticks
I also suggest keeping an array of calculated times. If something causes your app to slow down, this will auto compensate:
TotalSecondsCalcs() as Integer[/quote]
Ticks is simply the number of 60th a second since the computer was turned on.
The principle of estimating time to completion is simple, really. This should work :
StartTime = Ticks
Ticks-StartTime
to verify the timer did fire its action event exactly at one minute (60*60 ticks)I think what Greg means is that as read/write speed may vary, you have to recalculate the estimation regularly to compensate for variations. If you set your timer to multiple, it will just do that.
So if i built it like this:
starttime= Ticks
Submit button
Launches copying process
Launches Timer 1
Timer1 set to Mode 2 (checking every 2 seconds)
Timer 1 has code: Ticks-Startime
dim start as Integer
dim atend as Integer
dim percent as Integer
start = val(FormatBytes(status.BytesComplete)) — How many MB have been completed
atend = val(FormatBytes(status.TotalBytes)) – TOTAL Size of MB
percent = start / atend * 100
label1.text = ((Ticks-StartTime)*(100/percent))/60
[quote=108183:@Jay maxted]So if i built it like this:
starttime= Ticks
Submit button
Launches copying process
Launches Timer 1
Timer1 set to Mode 2 (checking every 2 seconds)
Timer 1 has code: Ticks-Startime
dim start as Integer
dim atend as Integer
dim percent as Integer
start = val(FormatBytes(status.BytesComplete)) — How many MB have been completed
atend = val(FormatBytes(status.TotalBytes)) – TOTAL Size of MB
percent = start / atend * 100
label1.text = ((Ticks-StartTime)*(100/percent))/60[/quote]
Look OK.
The reason I suggested keeping multiple calculations of the speed has to do with the fact that many operations are disproportionally fast or slow when they first begin. This can throw your calculations way off. For instance, if you are copying a bunch of little files, as opposed to one large one, you may incur some overhead from how the OS negotiates the copy.
Building a Play App exactly as i described above:
** Windows 1 **
starttime = ticks
Run - Fail “The item doesn’t exist”
[quote=108193:@Jay maxted]Building a Play App exactly as i described above:
** Windows 1 **
starttime = ticks
Run - Fail “The item doesn’t exist”[/quote]
Dim StartTime as integer