根据事件计算进度百分比
我必须实现一个进度条来显示报告生成的进度,问题是我必须根据生成生成的事件来表示报告进度的百分比,但首先不知道事件的总量,例如报告生成发送以下事件(阶段):
- Starting Report generation
- Start Query execution
- End Query execution
- Start Report Rendering
- End Report Rendering
- End Report Generation
在此示例中,总共有 3 个任务和 6 个事件,我不知道任务总数,但我知道事件总数是任务数量的两倍。
我不知道存在哪些事件以及有多少,但我必须用进度条表示进度,因此使用 0 到 100 之间的数字。
如何计算?代表进展的最佳方式是什么?
I have to implement a progressbar that show the progress of a report generation, the problem is that i have to represent the percentage of the report progression based on event generated by the generation but without first knowing the total amount of event, so for example the report generation sends the following event(phase) :
- Starting Report generation
- Start Query execution
- End Query execution
- Start Report Rendering
- End Report Rendering
- End Report Generation
In this example there are in total 3 task and 6 events, i don't know the total number of task but i know that the total number of events is twice respect the number of tasks.
I don't know which events are present and how many they are , but i have to represent the progression with a progress bar so with a number between 0 and 100 .
How can it be calculated ? Whats the best way to represents the progression ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许你能做的最好的事情就是完全放弃实际进度条的想法,并起诉一些不确定的进度指示器。在桌面系统上的这种情况下,通常使用“选取框”或“弹跳”进度条。
另一种选择 - 如果你真的想展示一些类似进展的东西 - 是采用一些启发式方法并且只是(部分)伪造它。您在这里实际上没有太多信息,因此它必须非常聪明,并且需要对真实案例进行大量测试。以下是一些建议:
根据当前处理任务的嵌套级别增加进度。基本上,这个想法是任务越细粒度,对整体进度的贡献就越小。当然,我所说的任务嵌套是指从
Start
和End
消息的括号中隐含的层次结构。合理估计您可以预期的最大任务数,并根据您距离完成的距离调整进度增加的速度。例如,如果您预计任务数量不会超过 500 个,而您已处理了 300 个任务,但已显示 80% 的进度,则必须严重放慢任何进一步的增长速度。同样,如果你落后了,你应该适当增加进度增量。
避免大幅跳跃。即使您需要快速赶上,如前一点所述,也要随着时间的推移逐步进行。举一个具体的例子:不要增加一次 10%,然后静止 10 秒,而是在 10 秒的过程中增加 10 次,每次增加 1%。
您可能还可以尝试使用更多技术。总的来说,这是一个非常有趣的用户体验和数学相关问题,但您应该考虑是否值得为此花费认知精力。我预计在大多数情况下,不确定的进度绝对没问题。
Probably the best you can do is to abandon the idea of actual progress bar altogether, and sue some indeterminate progress indicator instead. A "marquee" or "bouncing" progress bar is typically used in this scenario on desktop systems.
Another option - if you really want to show something progress-like - is to employ some heuristics and just (partially) fake it. You don't really have many information here so it would have to be pretty clever, and require a lot of testing on real cases. Here's some suggestions:
Increase the progress based on the nesting level of currently processed task. Basically, the idea is that the more fine grained the task is, the less it contributes to the overall progress. By task nesting I mean, of course, the hierarchy implied from bracketing of your
Start
andEnd
messages.Get a reasonable estimate of the maximum number of tasks you can expect, and adjust the speed of progress' increase based on how close you might be to finishing. For example, if you expect no more than 500 tasks, and you have processed 300 but are already displaying 80% progress, you must seriously slow down any further increase. Similarly, if you are lagging behind, you should appropriate scale up you progress increments.
Avoid big jumps. Even if you need to rapidly catch up, as described in previous point, do so gradually and over time. To put up a concrete example: rather than incrementing once by 10% and then stand still for 10 seconds, make 10 increments of 1% each over the course of 10 seconds.
There are probably many more techniques you could try to use. Overally, it's quite an interesting UX- and math-related problem, but you should consider whether spending cognitive effort on it is worth the hassle. I expect that in most cases, the indeterminate progress would be absolutely fine.
使用正常的进度条是不可能实现您所要求的,因为您基本上不知道您要跟踪的进度。您可以做的是有一个选框进度条(无限期地继续前进的进度条)向用户显示您的应用程序仍在运行,并且在其上方或下方,有一个不可编辑的文本框,其中显示您上面提到的任务。
What you require is not possible with a normal progress bar since you basically have no clue of the progress which you are trying to track down. What you can do is to have a marquee progress bar (a progress bar which keeps going indefinitely) to show the user that your application is still going and above or below it, have a non editable text box which dhows the tasks you have mentioned above.