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:
- A web server often has a static files directory (e.g. .html, .js,, .css).
- The viewer page and its supporting files don't have to be assembled by scalene, but can live as static files.
- 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.)
- 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.
- 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.
- 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.
- This assumes you have a default port number that can also be changed with a command-line flag.
- If you're feeling wild and crazy, perhaps the app could use an optional configuration file.
- 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.
Prior discussion
Emery:
Unpacking the idea:
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.profile{$timestamp}.jsonor, optionally,profile-$appname-$timestamp.jsonwith the prefix coming from a command-line flag.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, andscalene --viewercould remain grandfathered in.