GMail Mailbox Size, Algorithm and Projection

I am here in Helsinki (Finland) now and just thought of checking the Detroit time by changing the windows date time control’s Time Zone. I was having the gmail login page in the background with size information - “Over 5090.355697 megabytes (and counting) of free storage so you’ll never need to delete another message”.

I thought of playing a bit on the calender control and noticed that the gmail mailbox counter is varying based on the system date. After checking the java script source, I realized that gmail script is dependent on the local system date. Hence thought of projecting the mailbox size for next 35 years. Unfortunately the script failed after 2038, it shows the size less than 5 MB. Hope google will correct the script by that time. Here is the projection of mailbox size.

gmailbox.png

If you are interested in the script code, here it is.


<script type=text/javascript>
<!--

var start_time = (new Date()).getTime();
var fixed = 0;

function el(id) {
if (document.getElementById) {
return document.getElementById(id);
} else if (window[id]) {
return window[id];
}
return null;
}
// Estimates of nanite storage generation over time.
var CP = [
[ 1175414400000, 2835 ],
[ 1192176000000, 2912 ],
[ 1193122800000, 4321 ],
[ 1199433600000, 6283 ],
[ 2147328000000, 43008 ],
[ 46893711600000, Number.MAX_VALUE ]
];
var quota;
var ONE_PX = "https://mail.google.com/mail/images/c.gif?t=" +
(new Date()).getTime();
function LogRoundtripTime() {
var img = new Image();
var start = (new Date()).getTime();
img.onload = GetRoundtripTimeFunction(start);
img.src = ONE_PX;
}

function OnLoad() {
if (!quota) {
quota = el("quota");
updateQuota();
}

}
function updateQuota() {
if (!quota) {
return;
}
var now = (new Date()).getTime();
var i;
for (i = 0; i < CP.length; i++) {
if (now < CP[i][0]) {
break;
}
}
if (i == 0) {
setTimeout(updateQuota, 1000);
} else if (i == CP.length) {
quota.innerHTML = CP[i - 1][1];
} else {
var ts = CP[i - 1][0];
var bs = CP[i - 1][1];
quota.innerHTML = format(((now-ts) / (CP[i][0]-ts) * (CP[i][1]-bs)) + bs);
//document.write(format(((now-ts) / (CP[i][0]-ts) * (CP[i][1]-bs)) + bs));
setTimeout(updateQuota, 1000);
}
}

var PAD = '.000000000';

function format(num) {
var str = String(num);
var dot = str.indexOf('.');
if (dot < 0) {
return str + PAD;
} if (PAD.length > (str.length - dot)) {
return str + PAD.substring(str.length - dot);
} else {
return str.substring(0, dot + PAD.length);
}
}

// -->
</script>

No Comments

Leave a reply