Visual studio VisualStudio中的宏第一次运行得非常慢,之后运行得很快

Visual studio VisualStudio中的宏第一次运行得非常慢,之后运行得很快,visual-studio,Visual Studio,我在VisualStudio中有一个宏,它插入一个带有当前日期和时间的C#注释。我在代码编辑器中使用它来输入带有时间戳的注释: // Inserts the date and time at the cursor position. var date = new Date(); var day = date.getDate(); var month = date.getMonth() + 1; var year = date.getYear(); var hours = date.getH

我在VisualStudio中有一个宏,它插入一个带有当前日期和时间的C#注释。我在代码编辑器中使用它来输入带有时间戳的注释:

// Inserts the date and time at the cursor position.

var date = new Date();

var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getYear();

var hours = date.getHours();
var minutes = date.getMinutes();

// Add a zero if single digit
if (day <= 9) day = "0" + day;
if (month <= 9) month = "0" + month;
if (minutes <= 9) minutes = "0" + minutes;
if (hours <= 9) hours = "0" + hours;

Macro.InsertText("//");
dte.ActiveDocument.Selection.NewLine();
Macro.InsertText("// " + month + "/" + day + "/" + year + ", " + hours + ":" + minutes);
dte.ActiveDocument.Selection.NewLine();
dte.ActiveDocument.Selection.LineUp(false, 2);
dte.ActiveDocument.Selection.EndOfLine();
Macro.InsertText(" ");
//在光标位置插入日期和时间。
变量日期=新日期();
var day=date.getDate();
var month=date.getMonth()+1;
var year=date.getYear();
var hours=date.getHours();
var minutes=date.getMinutes();
//如果为一位数,则添加零
如果(天)