Ejemplo n.º 1
0
def run(args):
  """
  Run a test with the specified parameters, and return the HTTP Archive
  (HAR) File represented as a dictionary.
  """
  har_gen = FlowProfiler(args.testfile, int(args.iterations))   \
            if args.iterations else FlowProfiler(args.testfile)

  # profiling_results is a list of lists containing HARs for each page in a run
  profiling_results = har_gen.profile()

  if args.average:
    return [merge_by_average(page_results) \
            for page_results in zip(*profiling_results)]
  else:
    return profiling_results[-1]
Ejemplo n.º 2
0
def run(args):
    """
  Run a test with the specified parameters, and return the HTTP Archive
  (HAR) File represented as a dictionary.
  """
    har_gen = FlowProfiler(args.testfile, int(args.iterations))   \
              if args.iterations else FlowProfiler(args.testfile)

    # profiling_results is a list of lists containing HARs for each page in a run
    profiling_results = har_gen.profile()

    if args.average:
        return [merge_by_average(page_results) \
                for page_results in zip(*profiling_results)]
    else:
        return profiling_results[-1]
Ejemplo n.º 3
0
        '-p',
        '--report',
        action='store_true',
        help='Call make_report.py to make a report and open it')

    args = arg_parser.parse_args()

    har_gen = FlowProfiler(args.testfile, int(
        args.iterations)) if args.iterations else FlowProfiler(args.testfile)

    # profiling_results is a list of lists containing HARs for each page in a run
    profiling_results = har_gen.profile()

    if args.average:
        chosen_result = [
            merge_by_average(page_results)
            for page_results in zip(*profiling_results)
        ]
    else:
        chosen_result = profiling_results[-1]

    result_text = json.dumps(chosen_result)
    filename = args.filename or 'data_{0}.json'.format(int(time.time()))

    if args.outputdir:
        output_file = os.path.join(args.outputdir, filename)
    else:
        if not os.path.isdir(DEFAULT_OUTPUT_DIR):
            os.mkdir(DEFAULT_OUTPUT_DIR)

        output_file = os.path.join(DEFAULT_OUTPUT_DIR, filename)
Ejemplo n.º 4
0
  arg_parser.add_argument('-f', '--filename', help="Used specified name for JSON file")
  arg_parser.add_argument('-u', '--urls', help='Comma separated URLs to profile')
  arg_parser.add_argument('-t', '--testfile', required=True, help='Use specified JSON test file to determine test actions')
  arg_parser.add_argument('-i', '--iterations', help='Do profiling task the specified number of times')
  arg_parser.add_argument('-a', '--average', action='store_true', help='Output the average results of the iterations')
  arg_parser.add_argument('-p', '--report', action='store_true', help='Call make_report.py to make a report and open it')

  args = arg_parser.parse_args()

  har_gen = FlowProfiler(args.testfile, int(args.iterations)) if args.iterations else FlowProfiler(args.testfile)

  # profiling_results is a list of lists containing HARs for each page in a run
  profiling_results = har_gen.profile()

  if args.average:
    chosen_result = [merge_by_average(page_results) for page_results in zip(*profiling_results)]
  else:
    chosen_result = profiling_results[-1]

  result_text = json.dumps(chosen_result)
  filename = args.filename or 'data_{0}.json'.format(int(time.time()))

  if args.outputdir:
    output_file = os.path.join(args.outputdir, filename)
  else:
    if not os.path.isdir(DEFAULT_OUTPUT_DIR):
      os.mkdir(DEFAULT_OUTPUT_DIR)

    output_file = os.path.join(DEFAULT_OUTPUT_DIR, filename)

  with open(output_file, 'w') as f: