Skip to content

Proposal: Serve results via a webserver (from PR #779 discussion) #781

@sarahec

Description

@sarahec

Prior discussion

What if the fix for headless servers is to write the page and test results (with unique names) to an external directory where they can be served via a web server? You can pass the result file name in a url parameter.

This would enable running batches of tests and reviewing them at leisure. It also opens the door to comparing the results of changes.

Emery:

Right now, the solution for headless servers is to output a JSON file (e.g., --json --outfile foo.json, or --no-browser which outputs profile.json) and load that file from scalene --viewer. I didn't quite follow the rest of your proposal, or at least how it would work in a common enough use case -- connection to some machine on Amazon or Azure or Google Cloud, where hosting a webserver is doable but maybe fraught?

Unpacking the idea:

  1. A web server often has a static files directory (e.g. .html, .js,, .css).
  2. The viewer page and its supporting files don't have to be assembled by scalene, but can live as static files.
  3. We still have to get the data into the viewer page, perhaps as a URL parameter. (Modern browsers also have a built-in file picker the page can use.)
  4. On a headless server, the setup can include a web server that sees that directory. Locally, in Python, the built-in web server module also supports static directories.
  5. Now the browser launch becomes open("https://${host}:${port}/viewer.html?profile=${profile-path}") . It works the same way locally or on the development server. Locally could use a temp dir and fixed name by default.
  6. You can support batch operation, etc. by writing the profile file as profile{$timestamp}.json or, optionally, profile-$appname-$timestamp.json with the prefix coming from a command-line flag.
  7. This assumes you have a default port number that can also be changed with a command-line flag.
  8. If you're feeling wild and crazy, perhaps the app could use an optional configuration file.
  9. Extreme option: allow gzipping the JSON files. The browser will decompress these automatically on load.

Granted, it's a lot of little changes -- changing page generation, how the page gets its data, updating the server, documentation, etc. -- so it could qualify as a major release. Having a series of runs available enables comparisons between them, taking multiple runs and averaging results, etc.

P.S. --outfile foo.json, --no-browser, and scalene --viewer could remain grandfathered in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions