Ability to use jiffy-web without sending measurements to server

28 views
Skip to first unread message

Jordi Albornoz Mulligan

unread,
Jan 20, 2009, 3:21:40 PM1/20/09
to jiffy-web
Hello,

I've recently started using jiffy-web and I am finding it very useful.
Particularly, the Firebug plug-in makes it
powerful even for quick, casual uses when the database recording and
reporting functionality isn't yet needed.

To that end, I think that the Jiffy-web JavaScript API would benefit
from a new configuration option to turn off the
upload of measurements to the server. I've included a patch that adds
a SEND_MEASURES option. When false, the server is never sent the
measurements.

I noticed that the comments in 'jiffy.js' describing the USE_JIFFY
option seem to incorrectly describe its behavior. My understanding of
its intention is to turn off all measurement functionality. The patch
follows this understanding to modify the documentation and disable the
'measure' method when USE_JIFFY is false.

I also noticed that the data inside the 'measures' object doesn't seem
to be used for anything. The 'addBulkLoad' method puts data into it
but nothing seems to read any data from there. So the patch also
removes those two apparently vestigial artifacts.

I hope you find that this patch helpful and that it improves this
useful tool.

--
Jordi Albornoz Mulligan


---------------------------
Index: javascript/jiffy.js
===================================================================
--- javascript/jiffy.js (revision 108)
+++ javascript/jiffy.js (working copy)
@@ -13,12 +13,7 @@
See the License for the specific language governing permissions
and
limitations under the License.
*/
-
var Jiffy = function (){
- this.addBulkLoad = function(_eventName, elapsedTime){
- measures.captured[_eventName] = elapsedTime;
- }
-
this.getUID = function(){
return Math.round(Math.random() * 1000000000000000);
}
@@ -44,12 +39,6 @@
var cMethod = 'get';

var markers = [];
- var measures = {
- pn:pname,
- st:pageTimer,
- uid:uid,
- captured:{}
- };
/* marks_measures
JSON Obj used for storing all captured marks and measures. This is
mainly used by the
Jiffy Firebug plugin but we use it for the bulk load operation.
sample layout of the
@@ -69,6 +58,7 @@
return{
// Creating a mark sets the startTime and lastTime to the curr
time
mark : function(referenceID){
+ if(Jiffy.options.USE_JIFFY == undefined || !Jiffy.options.USE_JIFFY)
{return};
var currTime = (new Date()).getTime();
markers[referenceID] = {startTime: currTime, lastTime: currTime};
},
@@ -108,18 +98,16 @@
markers["PageStart"] = {startTime: refStartTime, lastTime:
currTime};
addMarksMeasures("PageStart", _eventName, elapsedTime,
refStartTime); // pageTimer?
}
-
- if(Jiffy.options.ISBULKLOAD && _eventName != "unload"){
- addBulkLoad(_eventName, elapsedTime);
+
+ if(Jiffy.options.SEND_MEASURES && (!Jiffy.options.ISBULKLOAD ||
_eventName == "unload")){
+ var curMeasures = Jiffy.utils.formatMeasure
(_eventName,elapsedTime);
+ Jiffy.Ajax.report(cMethod,cUri,
{uid:uid,st:pageTimer,pn:pname,ets:curMeasures});
}
- else{
- var curMeasures = Jiffy.utils.formatMeasure
(_eventName,elapsedTime);
- Jiffy.Ajax.report(cMethod,cUri,
{uid:uid,st:pageTimer,pn:pname,ets:curMeasures});
- }
checkRemoveEvent(eventName);
},

_bulkLoad: function(){
+ if(!Jiffy.options.SEND_MEASURES){return};
var bulkmeasures = Jiffy.getMeasures();
var bulkmeasuresCount = bulkmeasures.length;
var measuresStr = "";
@@ -145,16 +133,19 @@
These can be overridden by providing a globally scoped hash named
'JiffyOptions' with
values for each option you would like to override.

- bool USE_JIFFY: This is stop all Jiffy code from executing calls to
the server log. This will allow you to have Jiffy mark and measure
tags in a page and still turn Jiffy off.
+ bool USE_JIFFY: When false, this stops Jiffy from creating any
marks or measures and it will prevent Jiffy from sending data to the
server. This is useful to remove any Jiffy execution overhead. Default
is 'true'.

- bool ISBULKLOAD: This will enable bulk loading of all Jiffy
measures to be sent in one call to the server logger.
+ bool SEND_MEASURES: When false, Jiffy will collect marks and
measures but will NOT send them to the server. This is useful when you
want to view the measures using a tool like the Jiffy Firebug plugin
(http://billwscott.com/jiffyext/). It avoids the need for the Jiffy-
web server infrastructure for quick and simple uses. Default is
'true'.
+
+ bool ISBULKLOAD: This will enable bulk loading of all Jiffy
measures to be sent in one call to the server logger. Default is
'true'.

object/hash BROWSER_EVENTS: These are builin events such as load
and unload events and the object to which we should attach a measure
callback to. These will automaticly be mmaeasured against the start
time mark.

- bool SOFT_ERRORS: In some functions we will use a try catch
statement and if these are enabled they will alert with the message or
the error. This is meant for ddeveloper debugging only and should left
to false in a production enviroment.
+ bool SOFT_ERRORS: In some functions we will use a try catch
statement and if these are enabled they will alert with the message or
the error. This is meant for developer debugging only and should left
to false in a production enviroment.
*/
Jiffy.options = {
- USE_JIFFY:true,
+ USE_JIFFY: true,
+ SEND_MEASURES: true,
ISBULKLOAD: true,
BROWSER_EVENTS: {"unload":window,"load":window},
SOFT_ERRORS: false
@@ -311,7 +302,7 @@
Jiffy.utils.on(objToBind,bEvents, Jiffy.measure);
}
}
- if(Jiffy.options.ISBULKLOAD){
+ if(Jiffy.options.SEND_MEASURES && Jiffy.options.ISBULKLOAD){
//Attach body onload to call bulk loader sending all data at once.
Jiffy.utils.on(window, "load", Jiffy._bulkLoad);
}

Scott Ruthfield

unread,
Jan 26, 2009, 2:32:20 PM1/26/09
to jiff...@googlegroups.com
Thanks, Jordi - I've also been unavailable but I'm going to take a look at this soon.

-Scott

ben maldonado

unread,
Jan 26, 2009, 8:32:18 PM1/26/09
to jiff...@googlegroups.com, jiff...@googlegroups.com
the use jiffy flag when set to false stopped jiffy from even collecting info for local use. I had done this in the case that there are lots of marks and measures I didn't want jiffy to execute anything, just for some back story. we should always support a way to turn it off completly by flipping a switch in a config on the server as a fail safe if something goes bad.  

ben 

Sent from my iPhone

Jordi Albornoz Mulligan

unread,
Jan 27, 2009, 10:57:48 AM1/27/09
to jiff...@googlegroups.com
On Mon, Jan 26, 2009 at 8:32 PM, ben maldonado <benmal...@gmail.com> wrote:
> the use jiffy flag when set to false stopped jiffy from even collecting info
> for local use. I had done this in the case that there are lots of marks and
> measures I didn't want jiffy to execute anything, just for some back story.
> we should always support a way to turn it off completly by flipping a switch
> in a config on the server as a fail safe if something goes bad.
> ben

I definitely agree. I believe the USE_JIFFY flag should completely
turn off collection of both marks and measures and any communication
to the server when set to false.

I believe that the SEND_MEASURES option I added can be used for the
case where you want marks and measures collected but don't want
communication with the server (because you want to use the Firebug
plugin, for example).

Those are my intentions in the patch.
--
Jordi Albornoz Mulligan
jo...@jenjordi.org

Scott Ruthfield

unread,
Jan 30, 2009, 12:29:11 PM1/30/09
to jiff...@googlegroups.com
I still haven't had time to look at this - Ben or someone else, have you had a chance? I'm hoping to look this weekend if not. 

ben maldonado

unread,
Jan 31, 2009, 9:36:23 PM1/31/09
to jiff...@googlegroups.com, jiff...@googlegroups.com
I am reviewing this patch tonight and will report my findings tomorrow. 

b. 

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages