The profiles
function dbSheetProfile() { var profile = []; var dbParameters = { "siloid": "multi", "dbid": "1yTQFdN_O2nFb9obm7AHCTmPKpf5cwAd78uNQJiCcjPk", "peanut": "bruce", "disablecache": true };
Next clear the sheet
// get the test data var profileTest = { "name": "TEST DATA", "functionName": "prepareTheData", "skip": false, "options": { "scale": 1 } };
Next, a reduction to bring all the test data together. In the example below I’m only getting one set of test data. As usual we’ll use the common function reduceTheResults(), that we’ve used in all the examples.
// next reduce the messages to one var profileReduction = []; profileReduction.push({ "name": "reduction", "functionName":"reduceTheResults", "debug":true, "options":{ } }); profile.push([profileTest],profileReduction);
Simulate a number of users doing a whole range of operations – in this case 5 at once, and then do another reduction
// get and process all the messages var CHUNKS = 5; var profileSheets = []; for (var i =0; i <CHUNKS;i++ ) { profileSheets.push ({ "name": "SHEET-"+i, "functionName": "bigTest", "skip": false, "options": { "driver": "cDriverSheet", "strain": "strain-"+i, "small": true, "parameters": dbParameters } }); } profile.push(profileSheets,profileReduction);
Finally we’ll need to log the results
profile.push( [ { "name": "LOG", "functionName": "logTheResults", "skip": false, "options": { "driver": "cDriverSheet", "clear": true, "parameters": { "siloid": "log", "dbid": "1yTQFdN_O2nFb9obm7AHCTmPKpf5cwAd78uNQJiCcjPk", "peanut": "bruce" } } } ]); return profile;
The only change we need to make now is to call this function to set up the run profile
function showSidebar() { // kicking off the sidebar executes the orchestration libSidebar('asyncService',ADDONNAME, dbSheetProfile () ); }
The executors
For more snippets like this see Google Apps Scripts snippets