Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Core/Data/DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public DvDateTimeZone(SysDateTimeOffset dto)
// Since it is constructed from a SysDateTimeOffset, all the validations should work.
var success = TryValidateOffset(dto.Offset.Ticks, out _offset);
Contracts.Assert(success);
_dateTime = ValidateDate(new DvDateTime(dto.DateTime), ref _offset);
_dateTime = ValidateDate(new DvDateTime(dto.UtcDateTime), ref _offset);

@TomFinley TomFinley May 11, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new DvDateTime(dto.UtcDateTime), ref _offset); [](start = 37, length = 46)

Interesting. I don't know that this is correct, singe this DateTimeZone exists to encode a local time including a datetime. So I think that this change here might be inappropriate and is in fact introducing data corruption.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing that out @TomFinley I will revert this change.

Contracts.Assert(!_dateTime.IsNA);
Contracts.Assert(!_offset.IsNA);
AssertValid();
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.ML.Core/Data/ProgressReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public CalculationInfo(int index, string name, ProgressChannel channel)
Index = index;
Name = name;
PendingCheckpoints = new ConcurrentQueue<KeyValuePair<DateTime, ProgressEntry>>();
StartTime = DateTime.Now;
StartTime = DateTime.UtcNow;
Channel = channel;
}
}
Expand Down Expand Up @@ -584,7 +584,7 @@ public ProgressEvent(int index, string name, DateTime startTime, ProgressEntry e
Index = index;
Name = name;
StartTime = startTime;
EventTime = DateTime.Now;
EventTime = DateTime.UtcNow;
Kind = EventKind.Progress;
ProgressEntry = entry;
}
Expand All @@ -597,7 +597,7 @@ public ProgressEvent(int index, string name, DateTime startTime, EventKind kind)
Index = index;
Name = name;
StartTime = startTime;
EventTime = DateTime.Now;
EventTime = DateTime.UtcNow;
Kind = kind;
ProgressEntry = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Data/Utilities/TimerScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Dispose()

// REVIEW: This is \n\n is to prevent changes across bunch of baseline files.
// Ideally we should change our comparison method to ignore empty lines.
_ch.Info("{0}\t Time elapsed(s): {1}\n\n", DateTime.Now, elapsedSeconds);
_ch.Info("{0}\t Time elapsed(s): {1}\n\n", DateTime.UtcNow, elapsedSeconds);

using (var pipe = _host.StartPipe<TelemetryMessage>("TelemetryPipe"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public unsafe void SetTreeScores(int idx, double[] scores)

private LassoFit GetLassoFit(IChannel ch, int maxAllowedFeaturesPerModel)
{
DateTime startTime = DateTime.Now;
DateTime startTime = DateTime.UtcNow;

if (maxAllowedFeaturesPerModel < 0)
{
Expand Down Expand Up @@ -450,7 +450,7 @@ private LassoFit GetLassoFit(IChannel ch, int maxAllowedFeaturesPerModel)
// First lambda was infinity; fixing it
fit.Lambdas[0] = Math.Exp(2 * Math.Log(fit.Lambdas[1]) - Math.Log(fit.Lambdas[2]));

TimeSpan duration = DateTime.Now - startTime;
TimeSpan duration = DateTime.UtcNow - startTime;
ch.Info("Elapsed time for compression: {0}", duration);

@TomFinley TomFinley May 11, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This in particular is a bit weird and doesn't really have an effect I'd think. Probably harmless though, plus UtcNow is much faster anyway so may as well use it.

Honestly this code here ought to have been using stopwatch. #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this has no effect. I have added a stopwatch here instead as per your suggestion


return fit;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.FastTree/TreeEnsemble/Ensemble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public string ToTreeEnsembleIni(FeaturesToContentMap fmap,

protected int AppendComments(StringBuilder sb, string trainingParams)
{
sb.AppendFormat("\n\n[Comments]\nC:0=Regression Tree Ensemble\nC:1=Generated using FastTree\nC:2=Created on {0}\n", DateTime.Now);
sb.AppendFormat("\n\n[Comments]\nC:0=Regression Tree Ensemble\nC:1=Generated using FastTree\nC:2=Created on {0}\n", DateTime.UtcNow);

string[] trainingParamsList = trainingParams.Split(new char[] { '\n' });
int i = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Maml/MAML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ internal static int MainCore(TlcEnvironment env, string args, bool alwaysPrintSt
Path.GetTempPath(),
"TLC");
var dumpFilePath = Path.Combine(dumpFileDir,
string.Format(CultureInfo.InvariantCulture, "Error_{0:yyyyMMdd_HHmmss}_{1}.log", DateTime.Now, Guid.NewGuid()));
string.Format(CultureInfo.InvariantCulture, "Error_{0:yyyyMMdd_HHmmss}_{1}.log", DateTime.UtcNow, Guid.NewGuid()));
bool isDumpSaved = false;
try
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.ResultProcessor/ResultProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ private static bool ValidateMamlOutput(string filename, string[] rawLines, out L
Results = runResults,
PerFoldResults = foldResults,
Time = 0,
ExecutionDate = DateTime.Now.ToString()
ExecutionDate = DateTime.UtcNow.ToString()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected virtual void InitCore(IChannel ch, int numFeatures, LinearPredictor pr
Contracts.Assert(Iteration == 0);
Contracts.Assert(Bias == 0);

ch.Trace("{0} Initializing {1} on {2} features", DateTime.Now, Name, numFeatures);
ch.Trace("{0} Initializing {1} on {2} features", DateTime.UtcNow, Name, numFeatures);
NumFeatures = numFeatures;

// We want a dense vector, to prevent memory creation during training
Expand Down Expand Up @@ -253,13 +253,13 @@ protected virtual void BeginIteration(IChannel ch)
Iteration++;
NumIterExamples = 0;

ch.Trace("{0} Starting training iteration {1}", DateTime.Now, Iteration);
ch.Trace("{0} Starting training iteration {1}", DateTime.UtcNow, Iteration);
// #if OLD_TRACING // REVIEW: How should this be ported?
if (Iteration % 20 == 0)
{
Console.Write('.');
if (Iteration % 1000 == 0)
Console.WriteLine(" {0} \t{1}", Iteration, DateTime.Now);
Console.WriteLine(" {0} \t{1}", Iteration, DateTime.UtcNow);
}
// #endif
}
Expand All @@ -269,7 +269,7 @@ protected virtual void FinishIteration(IChannel ch)
Contracts.Check(NumIterExamples > 0, NoTrainingInstancesMessage);

ch.Trace("{0} Finished training iteration {1}; iterated over {2} examples.",
DateTime.Now, Iteration, NumIterExamples);
DateTime.UtcNow, Iteration, NumIterExamples);

ScaleWeights();
#if OLD_TRACING // REVIEW: How should this be ported?
Expand Down Expand Up @@ -378,7 +378,7 @@ protected virtual void ProcessDataInstance(IChannel ch, ref VBuffer<Float> feat,
if (_numIterExamples % 5000000 == 0)
{
Host.StdOut.Write(" ");
Host.StdOut.Write(DateTime.Now);
Host.StdOut.Write(DateTime.UtcNow);
}
Host.StdOut.WriteLine();
}
Expand Down