Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When are data sections evaluated?

Tags:

powershell

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).

like image 435
Travis Avatar asked May 16 '19 16:05

Travis


People also ask

What are the 3 steps to evaluating data?

These steps and many others fall into three stages of the data analysis process: evaluate, clean, and summarize.

Why do we evaluate data?

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.

What is evaluation in data mining?

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.


1 Answers

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 section evaluation is executed immediately, not delayed
  • Data section is evaluated only once, not on every usage

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.

like image 70
AdamL Avatar answered Nov 08 '22 23:11

AdamL