private void Jitting() { SetupAction?.Invoke(); MainAction.Invoke(1); IdleAction.Invoke(1); CleanupAction?.Invoke(); }
public Measurement RunIteration(IterationData data) { // Initialization long invokeCount = data.InvokeCount; int unrollFactor = data.UnrollFactor; long totalOperations = invokeCount * OperationsPerInvoke; var action = data.IterationMode.IsIdle() ? IdleAction : MainAction; // Setup SetupAction?.Invoke(); GcCollect(); // Measure var clock = TargetJob.Infrastructure.Clock.Resolve(Resolver).Start(); action(invokeCount / unrollFactor); var clockSpan = clock.Stop(); // Cleanup CleanupAction?.Invoke(); GcCollect(); // Results var measurement = new Measurement(0, data.IterationMode, data.Index, totalOperations, clockSpan.GetNanoseconds()); WriteLine(measurement.ToOutputLine()); return(measurement); }
/// <summary> /// Get the action type from the action provided. /// </summary> /// <param name="action">The action being performed</param> /// <returns>The type of the action.</returns> public static CleanupActionType GetCleanUpActionType(CleanupAction action) { switch (action) { case CleanupAction.LOWERCASE: return(CleanupActionType.MODIFICATION); case CleanupAction.UPPERCASE: return(CleanupActionType.MODIFICATION); case CleanupAction.REMOVE: return(CleanupActionType.REMOVAL); case CleanupAction.REPORT: return(CleanupActionType.STATS); default: return(CleanupActionType.NULL); } }
/// <summary> /// Performs the clean up action on some sort of data value (for performing actions on the cell) /// </summary> /// <param name="action">The action to perform</param> /// <param name="input">The input to perform the action on</param> /// <param name="dataType">The data type of the input</param> /// <returns>The input value with the changes applied to it.</returns> public static object PerformCleanupAction(CleanupAction action, object input, Type dataType) { switch (action) { case CleanupAction.LOWERCASE: return(input.GetType() == typeof(string) ? ((string)input).ToLower() : input); case CleanupAction.UPPERCASE: return(input.GetType() == typeof(string) ? ((string)input).ToUpper() : input); case CleanupAction.REPORT: return(input); case CleanupAction.REMOVE: default: return(Activator.CreateInstance(dataType)); } }
/// <summary> /// Performs the clean up action on the provided datarow. /// </summary> /// <param name="action">The action to perform</param> /// <param name="input">The datarow to perform the action on.</param> public static object PerformCleanupAction(CleanupAction action, DataRow input) { switch (action) { case CleanupAction.LOWERCASE: foreach (DataColumn column in input.Table.Columns) { if (column.DataType == typeof(string)) { input[column] = input[column].ToString().ToLower(); } } return(null); case CleanupAction.UPPERCASE: foreach (DataColumn column in input.Table.Columns) { if (column.DataType == typeof(string)) { input[column] = input[column].ToString().ToUpper(); } } return(null); case CleanupAction.REMOVE: input.Delete(); return(null); case CleanupAction.REPORT: string value = ""; foreach (DataColumn column in input.Table.Columns) { value += input[column].ToString(); } return(value); default: return(null); } }
/// <summary> /// Adds a directory to the cleanup congfiguration /// </summary> /// <param name="path">File path for the directory</param> /// <param name="isRecursive">True for recursive cleanup. False for top level only</param> /// <param name="action"><see cref="CleanupAction"/> type</param> public void AddDirectory(string path, bool isRecursive, CleanupAction action) { if (!string.IsNullOrWhiteSpace(path)) { if (_config != null) { _logger.ShowInformation(string.Format("Adding directory: '{0}' Recursive: {1} Action: {2}", path, isRecursive, action)); lock (_config) { DirectoryConfiguration dir = null; foreach (DirectoryConfiguration d in _config.Directories) { if (string.Compare(path.TrimEnd('\\'), d.Path.TrimEnd('\\'), true) == 0) { dir = d; break; } } if (dir == null) { dir = new DirectoryConfiguration(); } else { _config.Directories.Remove(dir); } dir.Path = path; dir.CleanupAction = action; dir.Recursive = isRecursive; _config.Directories.Add(dir); SaveConfiguration(); } } } }
public CleanupTask(string user, CleanupAction action) { this.m_action = action; this.m_username = user.ToUpper(); this.m_time = DateTime.Now; }
/// <summary> /// Initializes a new instance of the <see cref="CleanupActionStatus" /> class. /// </summary> /// <param name="Action">Action.</param> /// <param name="Settings">Settings.</param> public CleanupActionStatus(CleanupAction Action = default(CleanupAction), CleanupActionSettings Settings = default(CleanupActionSettings)) { this.Action = Action; this.Settings = Settings; }
public CleanupTask(string user, CleanupAction action) { this.m_action = action; this.m_username = user.ToUpper(); this.m_time = DateTime.Now; }