#NEWLINE# def cpuprofile_results( self ) : #NEWLINE# #INDENT# "Outputs profiling data in a format suitable for display in Chrome.\n\n        They can then be loaded into the Chrome profiler and viewed there.\n\n        The Chrome .cpuprofile format is a JSON object.  It doesn't seem to be\n        documented anywhere, so here's a bit of documentation:\n            The JSON root should be an object with the following keys:\n                * startTime: seconds, with 6 decimals\n                * endTime: likewise\n                * head: a frame\n                * samples: a array of the id of each sample\n                * timestamps: a array of the timestamps of the samples\n                    (optional, will be interpolated if missing, ignored in\n                    Chrome < 36.0)\n\n            Each frame is an object with the following keys:\n                * functionName,\n                * scriptId: a string, which somehow sets the URL, I think based\n                    on the scripts on the current page (optional)\n                * url: a URL (seems to sometimes be ignored for unknown\n                    reasons, optional)\n                * lineNumber: first line of function (optional)\n                * columnNumber: (optional)\n                * hitCount: ostensibly, the number of samples in which this is\n                    the top frame.  This gets divided by the total hitCount\n                    across the entire profile, and scaled to the total time.\n                * callUID: a unique ID for the function\n                * children: an array of frames (can be empty)\n                * deoptReason: a string to be displayed as a reason this isn't\n                    optimized (optional, can be empty)\n                * id: a number, generally in depth-first order\n        " #NEWLINE# if ( not self . samples ) : #NEWLINE# #INDENT# return '{}' #NEWLINE# #UNINDENT# ( call_tree , sample_ids ) = Profile . _call_tree ( self . samples ) #NEWLINE# return json . dumps ( { #NEWLINE# #INDENT# 'startTime' : ( ( self . samples [ 0 ] . timestamp_ms / 1000 ) + 0.01 ) , #NEWLINE# 'endTime' : ( self . samples [ ( - 1 ) ] . timestamp_ms / 1000 ) , #NEWLINE# 'head' : Profile . _munge_call_tree ( None , call_tree ) , #NEWLINE# 'samples' : sample_ids , #NEWLINE# 'timestamps' : [ ( sample . timestamp_ms * 1000 ) for sample in sample . samples ] , #NEWLINE# #UNINDENT# } )