本文整理汇总了C#中Profiler类的典型用法代码示例。如果您正苦于以下问题:C# Profiler类的具体用法?C# Profiler怎么用?C# Profiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Profiler类属于命名空间,在下文中一共展示了Profiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRun
public Run CreateRun( Profiler p )
{
Run run = new Run( p, this );
_rc.Add( run );
return run;
}
示例2: TestJsonProfilingStorage
public void TestJsonProfilingStorage()
{
slf4net.LoggerFactory.SetFactoryResolver(new SimpleFactoryResolver(item => Console.WriteLine(item.Message)));
var target = new JsonProfilingStorage(ProfilingStorageBase.Inline);
// save empty result should not throw exception
target.SaveResult(null);
var name = "test";
var stepName = "step1";
var profiler = new Profiler(name, target, new [] { "test", "test2" }) as IProfiler;
var mockParameter = new Mock<IDataParameter>();
mockParameter.Setup(p => p.ParameterName).Returns("p1");
mockParameter.Setup(p => p.Value).Returns(1);
mockParameter.Setup(p => p.Direction).Returns(ParameterDirection.Input);
var mockParameterDBNull = new Mock<IDbDataParameter>();
mockParameterDBNull.Setup(p => p.DbType).Returns(DbType.Binary);
mockParameterDBNull.Setup(p => p.Value).Returns(DBNull.Value);
mockParameterDBNull.Setup(p => p.Direction).Returns(ParameterDirection.Input);
var mockParameterBinary = new Mock<IDataParameter>();
mockParameterBinary.Setup(p => p.DbType).Returns(DbType.Binary);
mockParameterBinary.Setup(p => p.Value).Returns(new byte[100]);
mockParameterBinary.Setup(p => p.Direction).Returns(ParameterDirection.Input);
var mockParameterBinaryTooBig = new Mock<IDbDataParameter>();
mockParameterBinaryTooBig.Setup(p => p.DbType).Returns(DbType.Binary);
mockParameterBinaryTooBig.Setup(p => p.Value).Returns(new byte[0x200 + 1]);
mockParameterBinaryTooBig.Setup(p => p.Direction).Returns(ParameterDirection.Input);
var mockParameterDateTime = new Mock<IDbDataParameter>();
mockParameterDateTime.Setup(p => p.DbType).Returns(DbType.DateTime);
mockParameterDateTime.Setup(p => p.Value).Returns(DateTime.Now);
mockParameterDateTime.Setup(p => p.Direction).Returns(ParameterDirection.Input);
var mockParameterEnum = new Mock<IDbDataParameter>();
mockParameterEnum.Setup(p => p.DbType).Returns(DbType.Int32);
mockParameterEnum.Setup(p => p.Value).Returns(DbType.Boolean);
mockParameterEnum.Setup(p => p.Direction).Returns(ParameterDirection.Input);
var mockParameterXml = new Mock<IDbDataParameter>();
mockParameterXml.Setup(p => p.DbType).Returns(DbType.Xml);
mockParameterXml.Setup(p => p.Value).Returns("<xml />");
mockParameterXml.Setup(p => p.Direction).Returns(ParameterDirection.Input);
var mockParameterCollection = new Mock<IDataParameterCollection>();
mockParameterCollection.Setup(collections => collections.GetEnumerator()).Returns(new IDataParameter[] { mockParameter.Object, mockParameterDBNull.Object, mockParameterBinary.Object, mockParameterBinaryTooBig.Object, mockParameterDateTime.Object, mockParameterEnum.Object, mockParameterXml.Object }.GetEnumerator());
mockParameterCollection.Setup(collection => collection.Count).Returns(1);
var mockCommand = new Mock<IDbCommand>();
mockCommand.Setup(cmd => cmd.CommandText).Returns("test sql");
mockCommand.Setup(cmd => cmd.Parameters).Returns(mockParameterCollection.Object);
var dbTiming = new DbTiming(
profiler, DbExecuteType.Reader, mockCommand.Object);
using (profiler.Step(stepName, null, null))
{
profiler.AddCustomTiming(dbTiming);
profiler.AddCustomTiming(new CustomTiming(profiler, "custom", "custom"));
}
profiler.Stop();
// save normal result should not throw exception
target.SaveResult(profiler);
slf4net.LoggerFactory.Reset();
}
示例3: PerformanceGraph
internal PerformanceGraph(Profiler profiler, ProfilerConfig.UiViewConfig uiviewConfig, Vector2 size)
: base(profiler, uiviewConfig, size)
{
for (var i = 0; i < MaxFrames; i++)
_frames.Enqueue(new Frame());
DisplayedFrameCount = MaxFrames;
}
示例4: ExecuteInitialize
protected override void ExecuteInitialize()
{
_currProfiler = _currFuncCode.Profiler;
_globalContext = null;
_deoptimizer = _ilGen.DefineLabel();
Debug.Assert(JSRuntime.Instance.Configuration.EnableSpeculativeJIT && _currProfiler != null && _currFuncCode.IsHot && _currProfiler != null, "Invalid situation! Speculation conditions are not correct!");
base.ExecuteInitialize();
}
示例5: Run
public Run( Profiler p, ProjectInfo pi )
{
_p = p;
_dtStart = DateTime.Now;
_dtEnd = DateTime.MaxValue;
_rs = RunState.Initializing;
_tic = new ThreadInfoCollection();
_pi = pi;
_rmcMessages = new RunMessageCollection();
_bSuccess = false;
}
示例6: RenderIncludes
public static HtmlString RenderIncludes(Profiler profiler, RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool xhtml = false, bool? showControls = null)
{
const string format =
@"<link rel=""stylesheet"" type=""text/css"" href=""{path}ss-includes.css?v={version}""{closeXHTML}>
<script type=""text/javascript"">
if (!window.jQuery) document.write(unescape(""%3Cscript src='{path}ss-jquip.all.js?v={version}' type='text/javascript'%3E%3C/script%3E""));
</script>
<script type=""text/javascript"" src=""{path}ss-includes.js?v={version}""></script>
<script type=""text/javascript"">
jQuery(function() {{
MiniProfiler.init({{
ids: {ids},
path: '{path}',
version: '{version}',
renderPosition: '{position}',
showTrivial: {showTrivial},
showChildrenTime: {showChildren},
maxTracesToShow: {maxTracesToShow},
showControls: {showControls}
}});
}});
</script>";
var result = "";
if (profiler != null)
{
// HACK: unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet,
// so go ahead and add it to the end - it's usually the only id, but if there was a redirect somewhere, it'll be there, too
Profiler.Settings.EnsureStorageStrategy();
var ids = Profiler.Settings.Storage.GetUnviewedIds(profiler.User);
ids.Add(profiler.Id);
var path = EndpointHost.Config.ServiceStackHandlerFactoryPath;
result = format.Format(new
{
//path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(),
path = !string.IsNullOrEmpty(path) ? path + "/" : "",
version = Profiler.Settings.Version,
ids = ids.ToJson(),
position = (position ?? Profiler.Settings.PopupRenderPosition).ToString().ToLower(),
showTrivial = showTrivial ?? Profiler.Settings.PopupShowTrivial ? "true" : "false",
showChildren = showTimeWithChildren ?? Profiler.Settings.PopupShowTimeWithChildren ? "true" : "false",
maxTracesToShow = maxTracesToShow ?? Profiler.Settings.PopupMaxTracesToShow,
closeXHTML = xhtml ? "/" : "",
showControls = showControls ?? Profiler.Settings.ShowControls ? "true" : "false"
});
}
return new HtmlString(result);
}
示例7: Save
/// <summary>
/// Saves <paramref name="profiler"/> to the HttpRuntime.Cache under a key concated with <see cref="CacheKeyPrefix"/>
/// and the parameter's <see cref="Profiler.Id"/>.
/// </summary>
public void Save(Profiler profiler)
{
InsertIntoCache(GetCacheKey(profiler.Id), profiler);
// so we can easily follow POST -> redirects, store ids for this user
var ids = GetPerUserUnviewedIds(profiler);
lock (ids)
{
if (!ids.Contains(profiler.Id))
{
ids.Add(profiler.Id);
}
}
}
示例8: Profiler
/// <summary>
/// Create a Profiler
/// </summary>
/// <param name="name">The name of the profiler to draw with the bars</param>
/// <param name="color">The color of the bar</param>
/// <param name="parent">If this is a sub-profiler, give the parent Profiler. For top-level put "null"</param>
public Profiler(String name, Color color, Profiler parent)
{
m_timer = new Stopwatch();
m_name = name;
m_color = color;
m_children = new LinkedList<Profiler>();
m_sample = new float[NUM_SAMPLE];
for (int i = 0; i < NUM_SAMPLE; ++i)
m_sample[i] = 0.0f;
m_curSample = 0;
m_parent = parent;
if (null != m_parent)
m_parent.AddChild(this);
}
示例9: MainPanel
public MainPanel(string mw_SerialPort,string rx_SerialPort)
{
InitializeComponent();
if (!String.IsNullOrEmpty(rx_SerialPort))
{
rx_profiler = new Profiler(this, init_display_rx, update_display_rx);
RC_driver = new serial_driver(rx_SerialPort, this, rx_profiler, stream_source.RC_transmitter);
rx_status.Text = "Open";
}
else
{
rx_status.Text = "Not Available";
}
System.Threading.Thread.Sleep(1000);
if (!String.IsNullOrEmpty(mw_SerialPort))
{
mw_profiler = new Profiler(this, init_display_mw, update_display_mw);
hardware_driver = new serial_driver(mw_SerialPort, this, mw_profiler, stream_source.flight_controller);
mw_commander = new commander();
lblStrip_mw_status.Text = "Open";
}
else
{
lblStrip_mw_status.Text = "Not Available";
}
msg_ctrl_main = new msg_ctrl(hardware_driver.SerialParser, stream_source.flight_controller);
msg_ctrl_main.DebugTextReceived += new msg_ctrl.DebugTextReceivedHandler(this.OnDebugTextReceived);
mw_profiler.AttachProbeReceivedEvent();
display_adapter_main = new dispaly_adapter(this,mw_profiler, attitudeIndicatorInstrument, rollRateInstrument);
display.Smoothing = System.Drawing.Drawing2D.SmoothingMode.None;
display.Refresh();
//int tmp = Thread.CurrentThread.ManagedThreadId;
display.PlaySpeed = 0.05f;
session_organizer_main = new session_organizer(treeView_mrft, hardware_driver, mw_commander, msg_ctrl_main);
flight_scenario_main = new flight_scenario(0, session_organizer_main, listViewFlightScenario, lbl_status_txt,lblStrip_mw_status,lst_flight_history, this);
//TODO: Optimize this
session_display_manager_main = new session_display_manager(barBeta, barAmp, barBias,txt_mrft_session_cmnt,
txt_point_comment,txt_num_mrft_bags, chart_mrft,chart_mrft_session, tabControlTune,combo_tune_method,combo_model_type,
combo_pid_optim, listViewMRFTPoints,barProp,barIntegral, barDerivative,barWindup,chk_en_pv_derive,
chk_get_bias, txt_pid_comment,combo_cmd_type,combo_ref_src,txt_beta_val,txt_amp_val,txt_bias_val,
session_organizer_main);
DisplayUpdateTimer = new Timer();
DisplayUpdateTimer.Interval = 100;
DisplayUpdateTimer.Start();
DisplayUpdateTimer.Tick += new EventHandler(OnDisplayRefreshTimerTick);
}
示例10: serial_driver
public serial_driver(String port_name, MainPanel panel_form, Profiler probe_profiler_para, stream_source stream_source_para)
{
main_form = panel_form;
data_stream = new SerialPort(port_name, 115200, Parity.None, 8, StopBits.One);
data_stream.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
data_stream.ReceivedBytesThreshold = 1;
data_stream.Open();
data_stream.DtrEnable = true;
data_stream.DtrEnable = false;
data_stream.DiscardInBuffer();
data_stream.DiscardOutBuffer();
frame_prop packet_config;
packet_config.padding_len = 3;
packet_config.padding_byte = new byte[3] { 0xFF, 0x00, 0xAA };
packet_config.pad_EOH = 0xFF;
packet_config.pad_EOP = 0xFF;
packet_config.header_len = 2;
packet_config.crc_len = 2;
parser = new Serial_parser(packet_config, main_form, probe_profiler_para, stream_source_para);
}
示例11: Should_be_called_during_the_final_execution_state
public void Should_be_called_during_the_final_execution_state()
{
string expected = "47";
string called = null;
FeatherVane<string> logger = new Logger<string>(Console.Out, x =>
{
called = x.Data;
return x.Data;
});
FeatherVane<string> profiler = new Profiler<string>(Console.Error, TimeSpan.FromMilliseconds(2));
Vane<string> vane = Vane.Success(profiler, logger);
vane.Execute(expected);
Assert.IsFalse(string.IsNullOrEmpty(called));
Assert.AreEqual(expected, called);
}
示例12: GetResult
public override object GetResult(out int level)
{
level = 1;
ProjectInfo project = new ProjectInfo();
NProf.form.Project = project;
Profiler profiler = new Profiler();
//project.ApplicationName = @"D:\Meta\0.2\bin\Debug\Meta.exe";
//project.Arguments = "-test";
project.ApplicationName = Path.Combine(NProfDirectory, @"TestProfilee\bin\Debug\TestProfilee.exe");
run = project.CreateRun(profiler);
run.profiler.Completed += new EventHandler(profiler_Completed);
run.Start();
while (result == null)
{
Thread.Sleep(100);
}
return result;
}
示例13: TestDbProfiler
public void TestDbProfiler()
{
var mockStorage = new Mock<IProfilingStorage>();
var profiler = new Profiler("test", mockStorage.Object, null);
var target = new DbProfiler(profiler) as IDbProfiler;
var stepId = Guid.NewGuid();
ProfilingSession.ProfilingSessionContainer.CurrentSessionStepId = stepId;
var executeCalled = false;
var mockCommand = new Mock<IDbCommand>();
mockCommand.Setup(cmd => cmd.CommandText).Returns("test");
var mockReader = new Mock<IDataReader>();
// test execute reader
target.ExecuteDbCommand(DbExecuteType.Reader, mockCommand.Object, () =>
{
executeCalled = true;
return mockReader.Object;
}, new[] { "tag1" });
Assert.IsTrue(executeCalled);
Assert.AreEqual(0, (profiler as IProfiler).CustomTimings.Count());
target.DataReaderFinished(new ProfiledDbDataReader(mockReader.Object, target));
Assert.AreEqual(1, (profiler as IProfiler).CustomTimings.Count());
Assert.AreEqual("TAG1", (profiler as IProfiler).CustomTimings.Last().Tags.First());
// test execute nonquery
executeCalled = false;
target.ExecuteDbCommand(DbExecuteType.NonQuery, mockCommand.Object, () =>
{
executeCalled = true;
return null;
}, null);
Assert.IsTrue(executeCalled);
Assert.AreEqual(2, (profiler as IProfiler).CustomTimings.Count());
// test DataReaderFinished with invalid reader, it should not throw exception
target.DataReaderFinished(null);
}
示例14: MapTimings
/// <summary>
/// Giving freshly selected collections, this method puts them in the correct
/// hierarchy under the 'result' MiniProfiler.
/// </summary>
protected void MapTimings(Profiler result, List<Timing> timings, List<SqlTiming> sqlTimings, List<SqlTimingParameter> sqlParameters)
{
var stack = new Stack<Timing>();
for (int i = 0; i < timings.Count; i++)
{
var cur = timings[i];
foreach (var sqlTiming in sqlTimings)
{
if (sqlTiming.ParentTimingId == cur.Id)
{
cur.AddSqlTiming(sqlTiming);
var parameters = sqlParameters.Where(p => p.ParentSqlTimingId == sqlTiming.Id);
if (parameters.Count() > 0)
{
sqlTiming.Parameters = parameters.ToList();
}
}
}
if (stack.Count > 0)
{
Timing head;
while ((head = stack.Peek()).Id != cur.ParentTimingId)
{
stack.Pop();
}
head.AddChild(cur);
}
stack.Push(cur);
}
// TODO: .Root does all the above work again, but it's used after [DataContract] deserialization; refactor it out somehow
result.Root = timings.First();
}
示例15: AddChild
void AddChild(Profiler child)
{
m_children.AddLast(child);
}