When are PowerShell data sections evaluated?
Specifically, are they only ever evaluated once at the point of runtime definition/loading? Or are they evaluated on every execution of the containing function, even if it has already been defined/loaded?
I'm assuming that the containing context is a function or advanced function that will be called multiple times in a single session after being defined/loaded, rather than a script file that would have to be reloaded on every invocation (as far as I understand, anyway).
These steps and many others fall into three stages of the data analysis process: evaluate, clean, and summarize.
Evaluation provides a systematic method to study a program, practice, intervention, or initiative to understand how well it achieves its goals. Evaluations help determine what works well and what could be improved in a program or initiative.
In data mining, pattern evaluation is the process of assessing the quality of discovered patterns. This process is important in order to determine whether the patterns are useful and whether they can be trusted.
Script to test for both questions:
(get-date).TimeOfDay.ToString()
Start-Sleep -Milliseconds 100
DATA dat -supportedCommand Get-Date {
get-date
}
Start-Sleep -Milliseconds 100
(get-date).TimeOfDay.ToString()
Start-Sleep -Milliseconds 100
$dat.TimeOfDay.ToString()
results (note that time from second line is the latest):
12:21:23.3191254
12:21:23.5393705
12:21:23.4306211
Which concludes that:
Data Sections would be much more useful if we had control over those mechanics. For example reading large text file only when needed or refreshing a variable upon every access.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With