Skip to content

Instantly share code, notes, and snippets.

@colinrgodsey
Created April 8, 2015 23:25
Show Gist options
  • Save colinrgodsey/dbc39d6c7a382e6a62bd to your computer and use it in GitHub Desktop.
Save colinrgodsey/dbc39d6c7a382e6a62bd to your computer and use it in GitHub Desktop.
mean preopt JS
$c_Lorg_HdrHistogram_LongHistogram.prototype.mean__D = (function() {
var itr = new $c_Lorg_HdrHistogram_LongHistogram$Iterator().init___Lorg_HdrHistogram_LongHistogram(
this);
var total = 0;
while ((itr.org$HdrHistogram$LongHistogram$Iterator$$bucketIndex$2 <
itr.org$HdrHistogram$LongHistogram$Iterator$$histogram$f
.bucketCount$1)) {
$m_Lorg_HdrHistogram_Histogram$();
var $$this = itr.org$HdrHistogram$LongHistogram$Iterator$$$undcountAtIndex$2;
if ((!(!(!$$this)))) {
var jsx$1 = true
} else if (((typeof $$this) !== "number")) {
var x = $uJ($$this);
var x$2 = $m_sjsr_RuntimeLong$().Zero$1;
var jsx$1 = ((x === null) ? (x$2 === null) : x.equals__O__Z(
x$2))
} else {
var jsx$1 = false
};
if ((!jsx$1)) {
$m_Lorg_HdrHistogram_Histogram$();
var $$this$2 = total;
var this$5 = $m_Lorg_HdrHistogram_Histogram$DynamicNumeric$();
$m_Lorg_HdrHistogram_Histogram$();
var $$this$1 = itr.org$HdrHistogram$LongHistogram$Iterator$$$undcountAtIndex$2;
var x$1 = this.medianEquivalentValue__Lorg_HdrHistogram_AbstractNumeric__Lorg_HdrHistogram_AbstractNumeric(
itr.org$HdrHistogram$LongHistogram$Iterator$$$undvalueFromIndex$2
);
$m_Lorg_HdrHistogram_Histogram$();
if ((!(!(!$$this$1)))) {
var jsx$3 = $uJ($m_sjsr_RuntimeLong$().Zero$1)
} else if (((typeof $$this$1) !== "number")) {
var jsx$3 = $uJ($$this$1)
} else {
$m_Lorg_HdrHistogram_Histogram$();
var x$3 = (($$this$1 >= (
$m_Lorg_HdrHistogram_Histogram$(), 0)) && (
$$this$1 <
$m_Lorg_HdrHistogram_Histogram$().org$HdrHistogram$Histogram$$TwoPow22D$1
));
if ((!(!(!(!x$3))))) {
var jsx$3 = $uJ(new $c_sjsr_RuntimeLong().init___I__I__I(
($$this$1 | 0), 0, 0))
} else {
var jsx$3 = $m_sjsr_RuntimeLong$().fromDouble__D__sjsr_RuntimeLong(
(+$$this$1))
}
};
$m_Lorg_HdrHistogram_Histogram$();
if ((!(!(!x$1)))) {
var jsx$2 = $uJ($m_sjsr_RuntimeLong$().Zero$1)
} else if (((typeof x$1) !== "number")) {
var jsx$2 = $uJ(x$1)
} else {
$m_Lorg_HdrHistogram_Histogram$();
var x$4 = ((x$1 >= ($m_Lorg_HdrHistogram_Histogram$(),
0)) && (x$1 <
$m_Lorg_HdrHistogram_Histogram$().org$HdrHistogram$Histogram$$TwoPow22D$1
));
if ((!(!(!(!x$4))))) {
var jsx$2 = $uJ(new $c_sjsr_RuntimeLong().init___I__I__I(
(x$1 | 0), 0, 0))
} else {
var jsx$2 = $m_sjsr_RuntimeLong$().fromDouble__D__sjsr_RuntimeLong(
(+x$1))
}
};
var x$6 = this$5.compact$extension__Lorg_HdrHistogram_AbstractNumeric__Lorg_HdrHistogram_AbstractNumeric(
jsx$3.$$times__sjsr_RuntimeLong__sjsr_RuntimeLong(
jsx$2));
total = $m_Lorg_HdrHistogram_Histogram$().org$HdrHistogram$Histogram$$DynamicNumericNative$1[
"plus"]
($$this$2, x$6)
};
itr.advance__V()
};
$m_Lorg_HdrHistogram_Histogram$();
var $$this$3 = total;
$m_Lorg_HdrHistogram_Histogram$();
var $$this$4 = this.$$undtotalCount$1;
return ((((typeof $$this$3) === "number") ? (+$$this$3) : $uJ(
$$this$3).toDouble__D()) / (((typeof $$this$4) ===
"number") ? (+$$this$4) : $uJ($$this$4).toDouble__D()))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment