Skip to content

Commit 9ecd00f

Browse files
Log module installation time (#814)
* Log the module installation time * Update tests
1 parent 02cc440 commit 9ecd00f

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/DependencyManagement/DependencySnapshotInstaller.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.DependencyManagement
99
using System.Collections.Generic;
1010
using System.Management.Automation;
1111
using System.Threading;
12+
using System.Diagnostics;
1213

1314
using Microsoft.Azure.Functions.PowerShellWorker.Utility;
1415

@@ -129,9 +130,12 @@ private void InstallModule(DependencyInfo module, string installingPath, PowerSh
129130
{
130131
try
131132
{
133+
var stopwatch = new Stopwatch();
134+
stopwatch.Start();
135+
132136
_moduleProvider.SaveModule(pwsh, module.Name, module.ExactVersion, installingPath);
133137

134-
var message = string.Format(PowerShellWorkerStrings.ModuleHasBeenInstalled, module.Name, module.ExactVersion);
138+
var message = string.Format(PowerShellWorkerStrings.ModuleHasBeenInstalled, module.Name, module.ExactVersion, stopwatch.ElapsedMilliseconds);
135139
logger.Log(isUserOnlyLog: false, LogLevel.Trace, message);
136140

137141
break;

src/resources/PowerShellWorkerStrings.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
<value>Started installing module '{0}' version '{1}'.</value>
180180
</data>
181181
<data name="ModuleHasBeenInstalled" xml:space="preserve">
182-
<value>Module name '{0}' version '{1}' has been installed.</value>
182+
<value>Module name '{0}' version '{1}' has been installed. Module installation completed in {2} ms.</value>
183183
</data>
184184
<data name="AcceptableFunctionAppDependenciesAlreadyInstalled" xml:space="preserve">
185185
<value>The function app has existing dependencies installed. Updating the dependencies to the latest versions will be performed in the background. New function app instances will pick up any new dependencies.</value>

test/Unit/DependencyManagement/DependencyManagementTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
namespace Microsoft.Azure.Functions.PowerShellWorker.Test
1313
{
14+
using System.Diagnostics;
1415
using System.Linq;
1516
using System.Management.Automation;
17+
using System.Threading;
1618

1719
public class DependencyManagementTests : IDisposable
1820
{
@@ -481,8 +483,12 @@ public void SaveModule(PowerShell pwsh, string moduleName, string version, strin
481483
{
482484
if (SuccessfulDownload || (SaveModuleCount >= ShouldNotThrowAfterCount))
483485
{
486+
var stopwatch = new Stopwatch();
487+
stopwatch.Start();
488+
Thread.Sleep(10); // wait for 10 milliseconds
489+
484490
// Save the module name and version for a successful download.
485-
DownloadedModuleInfo = string.Format(PowerShellWorkerStrings.ModuleHasBeenInstalled, moduleName, version);
491+
DownloadedModuleInfo = string.Format(PowerShellWorkerStrings.ModuleHasBeenInstalled, moduleName, version, stopwatch.ElapsedMilliseconds);
486492
return;
487493
}
488494

0 commit comments

Comments
 (0)