petenelson / progress-estimator Goto Github PK
View Code? Open in Web Editor NEWPHP library to estimate time remaining for a list of long-running tasks
License: MIT License
PHP library to estimate time remaining for a list of long-running tasks
License: MIT License
The current implementation takes the average execution time of each item to determine the estimated time remaining. Depending on the scenario, item processing may go slower for each item as the processing progresses, such as a large database migration that has more and more data to query, processing images in order of their file size, etc.
Let's say there are 100 items to process and processing time increases as they are processed. The first twenty items take one second each, the next twenty take five seconds each, and the next twenty take ten seconds each. Using the current implementation, that's an average of 5.3 seconds per item.
Rather than using an overall average, I'd like to implement a parameter in the constructor that takes a sample mode and a sample size. If we pass in a calculation mode of count
and a sample size of 40
, the code would look at the last forty items processed to get an average time of 7.5 seconds per item. This time would be used to calculate the estimated time remaining for the rest of the items to be processed. I would also like to allow for a calculation mode of percent
to look at the last X percent of items to get the average.
Examples:
// Use the last 40 items to determine an average.
$estimator = new \PHPEstimator\Estimator(
100,
['calculation_mode' => 'count', 'sample_size' => 40]
);
// Use the last 10 percent of the total items to determine an average.
$estimator = new \PHPEstimator\Estimator(
100,
['calculation_mode' => 'percent', 'sample_size' => 10]
);
The code would not switch over to using a different calculation mode until the number of items processed reaches the sample size.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.