Title: Add-Type ReadAllText perf improvement · Issue #5158 · PowerShell/PowerShell · GitHub
Open Graph Title: Add-Type ReadAllText perf improvement · Issue #5158 · PowerShell/PowerShell
X Title: Add-Type ReadAllText perf improvement · Issue #5158 · PowerShell/PowerShell
Description: Add-Type uses File.ReadAllText() API in a loop for reading in multiple source files. This can be non-performant for multiple reasons: a. ReadAllText() uses a small buffer that increases IO calls. b. It performs StringBuilder.ToString() i...
Open Graph Description: Add-Type uses File.ReadAllText() API in a loop for reading in multiple source files. This can be non-performant for multiple reasons: a. ReadAllText() uses a small buffer that increases IO calls. b...
X Description: Add-Type uses File.ReadAllText() API in a loop for reading in multiple source files. This can be non-performant for multiple reasons: a. ReadAllText() uses a small buffer that increases IO calls. b...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/5158
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add-Type ReadAllText perf improvement","articleBody":"Add-Type uses File.ReadAllText() API in a loop for reading in multiple source files. This can be non-performant for multiple reasons:\r\na. ReadAllText() uses a small buffer that increases IO calls.\r\nb. It performs StringBuilder.ToString() internally which allocates a string that is not used, making possible LOH allocation and adding GC pressure.\r\n\r\nConsider using a different pattern:\r\n```\r\nStringBuilder sourceCode = new StringBuilder();\r\n\r\nforeach (string file in paths)\r\n{\r\n foreach (string line in File.ReadAllLines(file))\r\n {\r\n sourceCode.AppendLine(line);\r\n }\r\n}\r\n\r\nString result = sourceCode.ToString();\r\n```","author":{"url":"https://github.com/PaulHigin","@type":"Person","name":"PaulHigin"},"datePublished":"2017-10-18T23:27:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/5158/PowerShell/issues/5158"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e0baccce-f850-a9fe-799c-67ce84de507f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87AC:2A1D55:52FD471:747F363:6A57108A |
| html-safe-nonce | 81777b5558522e8f96c740b8a59fc95af89b94a119580828fa685835efb5cc44 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0FDOjJBMUQ1NTo1MkZENDcxOjc0N0YzNjM6NkE1NzEwOEEiLCJ2aXNpdG9yX2lkIjoiNDE4MDg5NDI0NjMwMjU4NDk3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8ca9cbc3d66022c2257d29cb3bf432bd5587f719eb693920e5a1519d07f43cd6 |
| hovercard-subject-tag | issue:266674164 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/5158/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1a2a619c35718c1b1a69f3978d7b3ff761d775f1a7cf11e9689895b1692356c/PowerShell/PowerShell/issues/5158 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1a2a619c35718c1b1a69f3978d7b3ff761d775f1a7cf11e9689895b1692356c/PowerShell/PowerShell/issues/5158 |
| og:image:alt | Add-Type uses File.ReadAllText() API in a loop for reading in multiple source files. This can be non-performant for multiple reasons: a. ReadAllText() uses a small buffer that increases IO calls. b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | PaulHigin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2576d1f0198cf1588faf2edf27f1ed120903be10 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width