ruff/docs
Dhruv Manilawala 6f7d3cc798
Add option (-o/--output-file) to write output to a file (#4950)
## Summary

A new CLI option (`-o`/`--output-file`) to write output to a file
instead of stdout.

Major change is to remove the lock acquired on stdout. The argument is
that the output is buffered and thus the lock is acquired only when
writing a block (8kb). As per the benchmark below there is a slight
performance penalty.

Reference:
https://rustmagazine.org/issue-3/javascript-compiler/#printing-is-slow

## Benchmarks

_Output is truncated to only contain useful information:_

Command: `check --isolated --no-cache --select=ALL --show-source
./test-repos/cpython"`

Latest HEAD (361d45f2b2) with and without
the manual lock on stdout:

```console
Benchmark 1: With lock
  Time (mean ± σ):      5.687 s ±  0.075 s    [User: 17.110 s, System: 0.486 s]
  Range (min … max):    5.615 s …  5.860 s    10 runs

Benchmark 2: Without lock
  Time (mean ± σ):      5.719 s ±  0.064 s    [User: 17.095 s, System: 0.491 s]
  Range (min … max):    5.640 s …  5.865 s    10 runs

Summary
  (1) ran 1.01 ± 0.02 times faster than (2)
```

This PR:

```console
Benchmark 1: This PR
  Time (mean ± σ):      5.855 s ±  0.058 s    [User: 17.197 s, System: 0.491 s]
  Range (min … max):    5.786 s …  5.987 s    10 runs
 
Benchmark 2: Latest HEAD with lock
  Time (mean ± σ):      5.645 s ±  0.033 s    [User: 16.922 s, System: 0.495 s]
  Range (min … max):    5.600 s …  5.712 s    10 runs
 
Summary
  (2) ran 1.04 ± 0.01 times faster than (1)
```

## Test Plan

Run all of the commands which gives output with and without the
`--output-file=ruff.out` option:
* `--show-settings`
* `--show-files`
* `--show-fixes`
* `--diff`
* `--select=ALL`
* `--select=All --show-source`
* `--watch` (only stdout allowed)

resolves: #4754
2023-06-20 22:16:49 +05:30
..
assets Added logo and favicon for mkdocs (#2757) 2023-02-10 23:34:47 -05:00
.gitignore Add a preliminary tutorial (#3281) 2023-02-28 20:31:27 +00:00
configuration.md Add option (-o/--output-file) to write output to a file (#4950) 2023-06-20 22:16:49 +05:30
editor-integrations.md markdownlint: enforce 100 char max length (#4698) 2023-05-28 22:45:56 -04:00
faq.md [perflint] Add perflint plugin, add first rule PERF102 (#4821) 2023-06-13 01:54:44 +00:00
installation.md markdownlint: enforce 100 char max length (#4698) 2023-05-28 22:45:56 -04:00
requirements.txt Check docs formatting check (#4270) 2023-05-08 19:03:22 +00:00
tutorial.md Update tutorial doc typo (#5088) 2023-06-14 11:17:35 -04:00
usage.md Update links to point to Astral org (#4949) 2023-06-08 11:43:40 -04:00