git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
453628e
)
browser: precalculate row usage values
author
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 27 Apr 2017 13:51:38 +0000
(15:51 +0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Mon, 29 May 2017 17:21:27 +0000
(19:21 +0200)
Trade memory for speed.
browser.plp
patch
|
blob
|
history
diff --git
a/browser.plp
b/browser.plp
index 202f252d1d7d0c532698428374e74079f8c64ea2..a101d741e4fb2071e0499b9cd65b9c85601cae90 100644
(file)
--- a/
browser.plp
+++ b/
browser.plp
@@
-202,6
+202,8
@@
my $usagepct = 1; # score multiplier for 0..100 result
$usagepct = 100.01 / featurescore({ # yes for every possible version
map { $_ => { map {$_ => 'y'} map { @{$_} } @{$versions{$_}} } } keys %versions
});
$usagepct = 100.01 / featurescore({ # yes for every possible version
map { $_ => { map {$_ => 'y'} map { @{$_} } @{$versions{$_}} } } keys %versions
});
+$_->{usage} = featurescore($_->{stats}) * $usagepct
+ for values %{ $caniuse->{data} };
print '<table class="mapped">';
print '<col span="3">'; # should match first thead row
print '<table class="mapped">';
print '<col span="3">'; # should match first thead row
@@
-429,13
+431,12
@@
sub saybrowsercols {
sub sayusagecol {
my ($id) = @_;
sub sayusagecol {
my ($id) = @_;
- print '<td>', int
featurescore($caniuse->{data}->{$id}->{stats}) * $usagepct
;
+ print '<td>', int
$caniuse->{data}->{$id}->{usage}
;
}
say '<tbody>';
for my $id (sort {
}
say '<tbody>';
for my $id (sort {
- featurescore($caniuse->{data}->{$b}->{stats})
- <=> featurescore($caniuse->{data}->{$a}->{stats})
+ $caniuse->{data}->{$b}->{usage} <=> $caniuse->{data}->{$a}->{usage}
} keys %{ $caniuse->{data} }) {
$caniuse->{data}->{$id}->{stats} or next; # skip metadata [summary]
printf '<tr id="%s">', $id;
} keys %{ $caniuse->{data} }) {
$caniuse->{data}->{$id}->{stats} or next; # skip metadata [summary]
printf '<tr id="%s">', $id;