Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
<?xml version="1.0" encoding="UTF-8" ?>
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
  <ModulePrefs title="gadgets.rpc Performance/correctness tests: Gadget">
    <Require feature="rpc"/>
  <Content type="html">
      // Pre-onload message send., 'initial_gadget_message', null, 'Hello there! Pre-onload message sent successfully.');
      var cachebust = 'cachebust=' + Math.random();
      document.write('<scr' + 'ipt language="JavaScript" type="text/javascript" src="/gadgets/files/container/rpctest_perf.js?' + cachebust + '"></scr' + 'ipt>');
      // Register ping handler.
      gadgets.rpc.register('gadget_service_ping', function() {
        var queryConsole = document.getElementById('queryconsole');
        var numQueries = queryConsole.innerHTML;
        queryConsole.innerHTML = numQueries;
        var whoAsked = document.getElementById('whoasked');
        whoAsked.innerHTML = this.f;

      function appendChildGadget() {
        var childgadgetdiv = document.getElementById('childgadgetdiv');
        var parentDomain = gadgets.rpc.getDomainRoot(gadgets.util.getUrlParameters().parent);
        var myDomain = gadgets.rpc.getDomainRoot(window.location.href);
        var rpctoken = Math.round(Math.random() * 10000000);
        var childGadgetUrl = parentDomain + '/gadgets/ifr?url=' + parentDomain + '/gadgets/files/container/rpctest_childgadget.xml&parent=' + myDomain + '#rpctoken=' + rpctoken;
        childgadgetdiv.innerHTML = '<div><input type="button" value="Ping Parent (Container)" onclick="callGadgetServicePing();"/><hr/>' +
          '<div>Who-am-I query count: <span id="queryconsole">0</span>, last q from: <span id="whoasked"></span></div>' +
          '<div><iframe id="childgadget" name="childgadget" height=100 width=200 src="about:blank"></iframe></div>';
        document.getElementById("childgadget").src = childGadgetUrl;
        gadgets.rpc.setAuthToken('childgadget', rpctoken);

      function callGadgetServicePing() {, 'gadget_service_ping');

      // Initialize performance test onLoad.
    <div>gadgets.rpc Performance: "Gadget" page</div><hr/>
      document.write("<div>Parent relay: " + gadgets.rpc.getRelayUrl('..') + "</div><hr/>");
        <li>Number of messages to send:
          <select name="num_msgs" id="num_msgs">
            <option value="1" selected>1</option>
            <option value="10">10</option>
            <option value="100">100</option>
            <option value="1000">1000</option>
        <li>Message size:
          <select name="msg_size" id="msg_size">
            <option value="10">10 B</option>
            <option value="100">100 B</option>
            <option value="1024" selected>1 kB</option>
            <option value="10240">10 kB</option>
            <option value="102400">100 kB</option>
            <option value="1048576">1 MB</option>
          <input type="button" value="Start The Test!" onclick="runPerfTest();" />
    <div id="test_running" style="display:none;">
      Running test...
    <div id="results" style="display:none;">
      Results: Gadget-to-Container<br/>
      Messages: <span id="results_num_received"></span>, Bytes: <span id="results_bytes_received"></span> <span id="in_or_out"></span><br/>
      Time elapsed for test run: <span id="results_time_used"></span><br/>
      Messages/second: <span id="results_msgs_per_sec"></span><br/>
      Bytes/second: <span id="results_bytes_per_sec"></span>
    <div id="childgadgetdiv"><input type="button" value="Child Gadget Tests" onclick="appendChildGadget();"/></div>
New to GrepCode? Check out our FAQ X