Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
0380de97
Commit
0380de97
authored
24 years ago
by
Fredrik Noring
Browse files
Options
Downloads
Patches
Plain Diff
New progress system. Stderr is redirected to a file called dumpmodule.log.
Rev: src/dumpmodule.pike:1.13
parent
012c916c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dumpmodule.pike
+59
-25
59 additions, 25 deletions
src/dumpmodule.pike
with
59 additions
and
25 deletions
src/dumpmodule.pike
+
59
−
25
View file @
0380de97
...
...
@@ -12,8 +12,60 @@ string fakeroot(string s)
#define fakeroot(X) X
#endif
class ProgressBar
{
private constant width = 45;
private float phase_base, phase_size;
private int max, cur;
private string name;
void set_current(int _cur)
{
cur = _cur;
}
void set_phase(float _phase_base, float _phase_size)
{
phase_base = _phase_base;
phase_size = _phase_size;
}
void update(int increment)
{
cur += increment;
cur = min(cur, max);
float ratio = phase_base + ((float)cur/(float)max) * phase_size;
if(1.0 < ratio)
ratio = 1.0;
int bar = (int)(ratio * (float)width);
int is_full = (bar == width);
write("\r %-13s |%s%c%s%s %4.1f %% ",
name+":",
"="*bar,
is_full ? '|' : ({ '\\', '|', '/', '-' })[cur & 3],
is_full ? "" : " "*(width-bar-1),
is_full ? "" : "|",
100.0 * ratio);
}
void create(string _name, int _cur, int _max,
float|void _phase_base, float|void _phase_size)
/* NOTE: max must be greater than zero. */
{
name = _name;
max = _max;
cur = _cur;
phase_base = _phase_base || 0.0;
phase_size = _phase_size || 1.0 - phase_base;
}
}
ProgressBar progress_bar;
#define error(X) throw( ({ (X), backtrace() }) )
...
...
@@ -231,30 +283,11 @@ void dumpit(string file)
}
}
constant progress_width = 45;
int progress_bar = 0;
int progress_offset = 0;
int progress_max = 0;
void update_progress(string name, int cur, int max)
{
float ratio = (float)cur/(float)max;
int bar = (int)(ratio * (float)progress_width);
int is_full = bar == progress_width;
werror("\r %s: |%s%c%s%s %4.1f %% ",
name,
"="*bar,
is_full ? '|' : ({ '\\', '|', '/', '-' })[cur & 3],
is_full ? "" : " "*(progress_width-bar-1),
is_full ? "" : "|",
100.0 * ratio);
}
int main(int argc, string *argv)
{
/* Redirect all debug and error messages to a logfile. */
Stdio.File("dumpmodule.log", "caw")->dup2(Stdio.stderr);
foreach( (array)all_constants(), [string name, mixed func])
function_names[func]="efun:"+name;
...
...
@@ -290,8 +323,9 @@ int main(int argc, string *argv)
quiet = 2;
logfile = Stdio.File("dumpmodule.log","caw");
progress_bar = 1;
sscanf(argv[1], "%d,%d", progress_offset, progress_max);
progress_bar = ProgressBar("Precompiling",
@array_sscanf(argv[1], "%d,%d"),
0.2, 0.8);
argv = argv[2..];
}
...
...
@@ -299,7 +333,7 @@ int main(int argc, string *argv)
foreach(argv, string file)
{
if(progress_bar)
update_
progress
("Precompiling", progress_offset++, progress_max
);
progress
_bar->update(1
);
dumpit(file);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment