Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | function regress(DATAPOINTS,SX,SY,SXY,SX2) |
michael@0 | 6 | { |
michael@0 | 7 | b1 = (DATAPOINTS * SXY - SX * SY) / (DATAPOINTS * SX2 - SX * SX); |
michael@0 | 8 | b0 = (SY - b1 * SX ) / DATAPOINTS; |
michael@0 | 9 | return b1 " * x + " b0; |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | BEGIN { |
michael@0 | 13 | if (!Skip) Skip = 0; |
michael@0 | 14 | if (Interval) |
michael@0 | 15 | { |
michael@0 | 16 | Count = 0; |
michael@0 | 17 | IntervalCount = 0; |
michael@0 | 18 | } |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | NR>Skip { |
michael@0 | 22 | sx += $1; |
michael@0 | 23 | sy += $2; |
michael@0 | 24 | sxy += $1 * $2; |
michael@0 | 25 | sx2 += $1 * $1; |
michael@0 | 26 | #print NR " " sx " " sy " " sxy " " sx2 |
michael@0 | 27 | |
michael@0 | 28 | if (Interval) |
michael@0 | 29 | { |
michael@0 | 30 | if(Count == Interval-1) |
michael@0 | 31 | { |
michael@0 | 32 | IntervalCount += 1; |
michael@0 | 33 | |
michael@0 | 34 | print NR-Count, "-", NR, ": ", regress(Count,isx,isy,isxy,isx2); |
michael@0 | 35 | |
michael@0 | 36 | Count = 0; |
michael@0 | 37 | isx = 0; |
michael@0 | 38 | isy = 0; |
michael@0 | 39 | isxy = 0; |
michael@0 | 40 | isx2 = 0; |
michael@0 | 41 | } |
michael@0 | 42 | else |
michael@0 | 43 | { |
michael@0 | 44 | Count += 1; |
michael@0 | 45 | isx += $1; |
michael@0 | 46 | isy += $2; |
michael@0 | 47 | isxy += $1 * $2; |
michael@0 | 48 | isx2 += $1 * $1; |
michael@0 | 49 | } |
michael@0 | 50 | } |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | END { |
michael@0 | 54 | if(Interval) { |
michael@0 | 55 | print NR-Count, "-", NR, ": ", regress(Count,isx,isy,isxy,isx2); |
michael@0 | 56 | } |
michael@0 | 57 | print regress(NR-Skip, sx, sy, sxy, sx2); |
michael@0 | 58 | } |