private Idler(ILogFile log, Config config) { _log = log.WrapIfNull(); _counters = MyCounters.New<Counters>(log); _config = config; _jobs = new IdlerAction[0]; }
public virtual void MyTestInitialize() { Console.WriteLine(context.TestName.PadRight(90, '-')); counters = new Counters(); watch = new Stopwatch(); watch.Start(); }
private LineStreamReader(string host, int port, ILogFile log, TimeSpan? receiveTimeout) { _counters = new Counters(); _log = log; _host = host; _port = port; _receiveTimeout = receiveTimeout; _info = "{0}:{1}".Fmt(_host, _port); }
private RemoteDispatcher(string myself, IIoC ioc) { _myself = myself; _counters = new Counters(); _log = ioc.Resolve<ILogFile>(); _json = ioc.Resolve<IJsonEngine>(); _rrepo = ioc.Resolve<IRemoteRepo>(); _messenger = ioc.Resolve<IMessengerEngine>(); }
public override void Apply(Counters counters) { _counters = counters; for (var i = 0; i < _count.GetValue(X); i++) { var counter = _counterFactory().Initialize(Game); counters.Add(counter); _addedCounters.Add(counter); } }
private SignalsHub(SignalsConfig config) { _counters = new Counters(); var ioc = create_dependencies(config); _log = ioc.Resolve<ILogFile>(); _repo = ioc.Resolve<IHubRepo>(); _configRa = ioc.Resolve<ISignalsConfigRa>(); _messenger = ioc.Resolve<IMessengerEngine>(); _agents = ioc.Resolve<IAgentsEngine>(); _idler = ioc.Resolve<IIdler>(); _scheduler = ioc.Resolve<IEventScheduler>(); var target = wcf.SignalsHub.New(this); _host = WcfHost<comm.ISignalsHub>.NewAsync(_log, target); _serviceName = GetType().AsServiceName(); }
public void CreateMissingCollections() { var collections = mongoDatabase.ListCollections().ToList(); if (!collections.Exists(document => document["name"] == UserAuthCol)) mongoDatabase.CreateCollection(UserAuthCol); if (!collections.Exists(document => document["name"] == UserOAuthProviderCol)) mongoDatabase.CreateCollection(UserOAuthProviderCol); if (!collections.Exists(document => document["name"] == CountersCol)) { mongoDatabase.CreateCollection(CountersCol); var countersCollection = mongoDatabase.GetCollection<Counters>(CountersCol); Counters counters = new Counters(); countersCollection.InsertOne(counters); } }
public void CreateMissingCollections() { if (!mongoDatabase.CollectionExists(UserAuth_Col)) mongoDatabase.CreateCollection(UserAuth_Col); if (!mongoDatabase.CollectionExists(UserOAuthProvider_Col)) mongoDatabase.CreateCollection(UserOAuthProvider_Col); if (!mongoDatabase.CollectionExists(Counters_Col)) { mongoDatabase.CreateCollection(Counters_Col); var CountersCollection = mongoDatabase.GetCollection<Counters>(Counters_Col); Counters counters = new Counters(); CountersCollection.Save(counters); } }
private MessengerEngine(IIoC ioc) { _msg2failureHandler = new Dictionary<Type, Action<comm.IoMsg>> { {typeof(comm.PublishMsg), msg => update_failure_counters((comm.PublishMsg) msg)}, {typeof(comm.FilterInfo), msg => update_failure_counters((comm.FilterInfo) msg)}, {typeof(comm.TopicFilterMsg), msg => update_failure_counters((comm.TopicFilterMsg) msg)}, {typeof(comm.HeartbeatMsg), msg => update_failure_counters((comm.HeartbeatMsg) msg)} }; _counters = new Counters(); _configRa = ioc.Resolve<ISignalsConfigRa>(); var config = _configRa.Values; _cachedConfig = config; _log = ThrottledLog.NewSync(config.ThrottledLogTtl, ioc.Resolve<ILogFile>()); _hubUri = _configRa.MakeHubUri(); _connector = ioc.Resolve<IAgentConnector>(); _agents = AgentsRepo.NewSync(); }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Counters.deathCount = 0; Counters.minutes = 0; Counters.hours = 0; Counters.seconds = 0; SceneManager.LoadScene(0); } float gravity = Physics2D.gravity.y; spriteRenderer.color = char_Alpha; int sceneIndex = SceneManager.GetActiveScene().buildIndex; //Bölüm numarasını alır. //======================================================= SAĞA SOLA YÜRÜMEK ============================================================= float moveInput = Input.GetAxisRaw("Horizontal"); //horizontal = yatay demek, d ye basılınca 1 a ya basılınca -1 verir. x i belirtir. -1 sol 1 sağdır. velocity.x = Mathf.MoveTowards(velocity.x, speed * moveInput, walkAcceleration * Time.deltaTime); /* 3 argüman var, bunlar sırasıyla (ilk konum,son konum,ivme) dir. * velocity.x ilk durumda 0 dır, son konumu yani geleceği konum hız*yön dür.(Buradaki hız aslında 'kaç birim yürüyeceği'dir.) * ivme ise bildiğin gibi, arttırırsan daha hızlı gider azaltırsan daha yavaş. */ transform.Translate(velocity * Time.deltaTime); //karakteri yeni konumuna yerleştirir.. //AŞAĞIDAKİ KOD KARAKTERİN KAYMASINI ÖNLEYECEKTİR.. if (moveInput != 0) { velocity.x = Mathf.MoveTowards(velocity.x, speed * moveInput, walkAcceleration * Time.deltaTime); //Sağ veya Sol tuşlarına(d veya a & sağ ok veya sol ok) basılınca karakter yürür.. } else { velocity.x = Mathf.MoveTowards(velocity.x, 0, groundDeceleration * Time.deltaTime); /*else yani sağ veya sol tuşlarına basılmadığında karakterin hareketi: * 0 a doğru yürümek olur başka bir deyişle hızını 0 a düşürür,durur. * ve bunu groundDeceleration ivmesiyle yapar. */ } //burası //======================================================================================================================================== //=================================================== COLLİDER İÇİN KODLAR ============================================================== Collider2D[] hits = Physics2D.OverlapBoxAll(transform.position, boxCollider.size, transform.rotation.z); /*burada karakter ile 'collide' olan nesneleri toplayan bir liste yaptık * üç argüman var sırasıyla point,size,angle * point = collider veya hitbox'un ortası * size = collider boyutu, bizimkisi karakteri saran bir boxCollider componenti olacaktır. * angle açıdır, colliderı döndürmek için kullanılabilir. * SİZE,POİNT VE ANGLE İLE BİR COLLİDER OLUŞTURULUR, OverlapBoxAll İSE BU COLLİDER A ÇARPAN BAŞKA COLLİDERLARI YAZDIRIR.. BURASI ÇOKOMELLİ..:) * bu listenin ilk elemanları => ground , character(boxcollider) dir. başka bir cisme çarpınca yenisi eklenir. */ grounded = false; foreach (Collider2D hit in hits) //listedeki elemanları tarıyor... { if (hit == boxCollider) { /*buradaki boxColllider üstte tanımladığımız boxcollider2d dir. Yani karakterin kendi collideridir. * Karakter aslinda her zaman kendiyle "collide" oluyor, bunu engellemek için bunu yazdık.*/ continue; } switch (hit.tag) { case "Platform": grounded = true; break; case "Ground": grounded = true; break; case "Obstacle": Counters.IncreaseDeaths(); SceneManager.LoadScene(sceneIndex); //Ediörün en üstünde File > Build Settings 'den bölüm indexini görebilirsin ve yeni scene leri oraya sürükleyerek ekleyebilirsin .Örn. Level01 in indexi 0 dır. Engele çarpılınca yine Level01 i oynatacak(baştan başlatacak) break; case "RedPortal": gameObject.tag = "Immune"; levelChanger.FadeToLevel(); //portala girince ekranı karartır. StartCoroutine(WaitAndExitLevel(2)); //SceneManager.LoadScene(sceneIndex+1); //Portala girince index 1 artacak. Level01 indexi = 0 , Level02 ninki 1 dir. Level01 deyken portala girince index 1 artacak ve Level02 oynayacak. break; case "RedButton": grounded = true; break; case "BlueButton": grounded = true; break; case "ShrinkPortal": //levelChanger.Shrink(); //karakterin rengini değiştirecek animasyonu oynatır. speed = speedValue + 5; Left = spriteHandlerScript.SmallLeft; //Left ve right spritelarını küçük boyutlarıyla değiştir. Right = spriteHandlerScript.SmallRight; boxCollider.size = SmallColliderSize; jumpHeight = 2; continue; //collider ile çarpışmamasını, colliderin sadece bir şeyleri aktive etmesini vs. istiyorsan continue de. Bu durumda karakter küçültme portalına değince çarpmayacak, yoluna devam edebilecek.. case "Normalizer": //levelChanger.Normalize(); //karakterin rengini değiştirecek animasyonu oynatır. speed = speedValue; Left = spriteHandlerScript.NormalLeft; Right = spriteHandlerScript.NormalRight; boxCollider.size = NormalColliderSize; jumpHeight = 3; continue; //collider ile çarpışmamasını, colliderin sadece bir şeyleri aktive etmesini vs. istiyorsan continue de. Bu durumda karakter küçültme portalına değince çarpmayacak, yoluna devam edebilecek.. case "JumpPad": velocity.y = Mathf.Sqrt(Mathf.Abs(gravity) * 4 * jumpHeight); grounded = false; break; } ColliderDistance2D colliderDistance = hit.Distance(boxCollider); //distance = çarpılan collider (hit) ile argüman olarak verilen collider (boxCollider yani karakterin collideri) arasındaki mesafeyi belirtir. if (colliderDistance.isOverlapped) //isOverlapped = True ise colliderin içine girmiş (bir nevi noclip olmuş) demektir. { transform.Translate(colliderDistance.pointA - colliderDistance.pointB); //karakteri colliderin gerisine atıyor. } } //====================================================================================================================== //==================================================== ZIPLAMA ========================================================= if (grounded == true) { velocity.y = 0; //Karakter bir platformun üzerindeyken y sini sıfırla. Bu olmasaydı 250.satırdaki kod, karakteri aşağı doğru hareket ettirecekti. if (Input.GetMouseButtonDown(0)) //Input.GetMouseButton = basılı tutunca ,, Input.GetMouseButtonDown = basınca ,, Jump = Space. { velocity.y = Mathf.Sqrt(2 * jumpHeight * Mathf.Abs(gravity)); /*Sol tık a basılınca karakter y sini arttır. Aşağı geri düşmesini bir alt satırda yapıyoruz. * Mathf.Abs(Pysics2D.gravity.y) kullanılmasaydı karakterin y si azalırdı dolayısıyla zıplayamazdı.(Bu yüzden gravity.y yi pozitif yapmalıyız.) gravity = physics2.gravity.y * Çünkü gravity.y negatif olabilirdi. Yerdeyken abs. (mutlak değer) kullanılmasa hata veriyor. */ } } velocity.y += gravity * Time.deltaTime; //bu satırda zıpladıktan sonra karaktere gravity uygulanılır ve karakter aşağı iner. Karakter yavaş zıplıyorsa gravity yi değiştir. //Physics2D.gravity default olarak (0,-25) e eşittir. Edit > Project Settings > Physics 2D den değiştirilebilir. }
public static void Main(string[] args) { if (args.Length < minArgs) { System.Console.Out.WriteLine(usage.ToString()); System.Environment.Exit(-1); } ITreebankLangParserParams tlpp = new EnglishTreebankParserParams(); DiskTreebank tb = null; string encoding = "UTF-8"; string puncTag = null; for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("-")) { switch (args[i]) { case "-l": { Language lang = Language.ValueOf(args[++i].Trim()); tlpp = lang.@params; break; } case "-e": { encoding = args[++i]; break; } default: { System.Console.Out.WriteLine(usage.ToString()); System.Environment.Exit(-1); break; } } } else { puncTag = args[i++]; if (tb == null) { if (tlpp == null) { System.Console.Out.WriteLine(usage.ToString()); System.Environment.Exit(-1); } else { tlpp.SetInputEncoding(encoding); tlpp.SetOutputEncoding(encoding); tb = tlpp.DiskTreebank(); } } tb.LoadPath(args[i]); } } ICounter <string> puncTypes = new ClassicCounter <string>(); foreach (Tree t in tb) { IList <CoreLabel> yield = t.TaggedLabeledYield(); foreach (CoreLabel word in yield) { if (word.Tag().Equals(puncTag)) { puncTypes.IncrementCount(word.Word()); } } } IList <string> biggestKeys = new List <string>(puncTypes.KeySet()); biggestKeys.Sort(Counters.ToComparatorDescending(puncTypes)); PrintWriter pw = tlpp.Pw(); foreach (string wordType in biggestKeys) { pw.Printf("%s\t%d%n", wordType, (int)puncTypes.GetCount(wordType)); } pw.Close(); }
internal void ExitCounter(Counters counter) { #if GRIDPARANOIA if (_counters != null) { Debug.Assert((int)counter < _counters.Length); int i = (int)counter; long l; QueryPerformanceCounter(out l); l = Cost(_counters[i].Start, l); _counters[i].Total += l; _counters[i].Calls++; _hasNewCounterInfo = true; } #endif // GRIDPARANOIA }
private IoSink(IIoC ioc) { _log = ioc.Resolve<ILogFile>(); _que = ioc.Resolve<IIoQueue>(); _counters = new Counters(); }
partial void DeleteCounters(Counters instance);
private void attach_Counters(Counters entity) { this.SendPropertyChanging(); entity.Facility = this; }
public void Compile() { Log.Clear(); Counters.Clear(); HasCompileError = true; var compiler = new MosaCompiler(GetCompilerExtensions()); try { CompileStartTime = DateTime.Now; CompiledFile = Path.Combine(LauncherOptions.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile)}.bin"); compiler.CompilerOptions.EnableSSA = LauncherOptions.EnableSSA; compiler.CompilerOptions.EnableIROptimizations = LauncherOptions.EnableIROptimizations; compiler.CompilerOptions.EnableSparseConditionalConstantPropagation = LauncherOptions.EnableSparseConditionalConstantPropagation; compiler.CompilerOptions.EnableInlinedMethods = LauncherOptions.EnableInlinedMethods; compiler.CompilerOptions.InlinedIRMaximum = LauncherOptions.InlinedIRMaximum; compiler.CompilerOptions.EnableIRLongExpansion = LauncherOptions.EnableIRLongExpansion; compiler.CompilerOptions.TwoPassOptimizations = LauncherOptions.TwoPassOptimizations; compiler.CompilerOptions.EnableValueNumbering = LauncherOptions.EnableValueNumbering; compiler.CompilerOptions.OutputFile = CompiledFile; compiler.CompilerOptions.Architecture = SelectArchitecture(LauncherOptions.PlatformType); compiler.CompilerOptions.LinkerFormatType = LauncherOptions.LinkerFormatType; compiler.CompilerOptions.MultibootSpecification = LauncherOptions.MultibootSpecification; compiler.CompilerOptions.SetCustomOption("multiboot.video", LauncherOptions.VBEVideo ? "true" : "false"); compiler.CompilerOptions.SetCustomOption("multiboot.width", LauncherOptions.Width.ToString()); compiler.CompilerOptions.SetCustomOption("multiboot.height", LauncherOptions.Height.ToString()); compiler.CompilerOptions.SetCustomOption("multiboot.depth", LauncherOptions.Depth.ToString()); compiler.CompilerOptions.BaseAddress = LauncherOptions.BaseAddress; compiler.CompilerOptions.EmitAllSymbols = LauncherOptions.EmitAllSymbols; compiler.CompilerOptions.EmitStaticRelocations = LauncherOptions.EmitStaticRelocations; compiler.CompilerOptions.EnableMethodScanner = LauncherOptions.EnableMethodScanner; compiler.CompilerOptions.CreateExtraSections = LauncherOptions.CreateExtraSections; compiler.CompilerOptions.CreateExtraProgramHeaders = LauncherOptions.CreateExtraProgramHeaders; if (LauncherOptions.GenerateMapFile) { compiler.CompilerOptions.MapFile = Path.Combine(LauncherOptions.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile)}.map"); } if (LauncherOptions.GenerateCompileTimeFile) { compiler.CompilerOptions.CompileTimeFile = Path.Combine(LauncherOptions.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile)}-time.txt"); } if (LauncherOptions.GenerateDebugFile) { var debugFile = LauncherOptions.DebugFile ?? Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile) + ".debug"; compiler.CompilerOptions.DebugFile = Path.Combine(LauncherOptions.DestinationDirectory, debugFile); } if (!Directory.Exists(LauncherOptions.DestinationDirectory)) { Directory.CreateDirectory(LauncherOptions.DestinationDirectory); } compiler.CompilerTrace.SetTraceListener(traceListener); if (string.IsNullOrEmpty(LauncherOptions.SourceFile)) { AddOutput("Please select a source file"); return; } else if (!File.Exists(LauncherOptions.SourceFile)) { AddOutput($"File {LauncherOptions.SourceFile} does not exists"); return; } compiler.CompilerOptions.AddSourceFile(LauncherOptions.SourceFile); compiler.CompilerOptions.AddSearchPaths(LauncherOptions.Paths); var inputFiles = new List <FileInfo> { (LauncherOptions.HuntForCorLib) ? HuntFor("mscorlib.dll") : null, (LauncherOptions.PlugKorlib) ? HuntFor("Mosa.Plug.Korlib.dll") : null, (LauncherOptions.PlugKorlib) ? HuntFor("Mosa.Plug.Korlib." + LauncherOptions.PlatformType.ToString() + ".dll"): null, }; compiler.CompilerOptions.AddSourceFiles(inputFiles); compiler.CompilerOptions.AddSearchPaths(inputFiles); compiler.Load(); compiler.Initialize(); compiler.Setup(); // TODO Include Unit Tests if (LauncherOptions.EnableMultiThreading) { compiler.ThreadedCompile(); } else { compiler.Compile(); } Linker = compiler.Linker; TypeSystem = compiler.TypeSystem; if (LauncherOptions.ImageFormat == ImageFormat.ISO) { if (LauncherOptions.BootLoader == BootLoader.Grub_0_97 || LauncherOptions.BootLoader == BootLoader.Grub_2_00) { CreateISOImageWithGrub(CompiledFile); } else // assuming syslinux { CreateISOImageWithSyslinux(CompiledFile); } } else { CreateDiskImage(CompiledFile); if (LauncherOptions.ImageFormat == ImageFormat.VMDK) { CreateVMDK(); } } if (LauncherOptions.GenerateNASMFile) { LaunchNDISASM(); } if (LauncherOptions.GenerateASMFile) { GenerateASMFile(); } HasCompileError = false; } catch (Exception e) { HasCompileError = true; AddOutput(e.ToString()); } finally { compiler = null; } }
private async Task ProcessEventsCoreAsync(ProcessEventsInput input, ContentLocationEventDataSerializer eventDataSerializer, int index) { var context = input.State.Context; var counters = input.State.EventStoreCounters; try { await context.PerformOperationAsync( Tracer, async() => { int filteredEvents = 0; foreach (var message in input.Messages) { // Extracting information from the message var foundEventFilter = message.Properties.TryGetValue(EventFilterKey, out var eventFilter); message.Properties.TryGetValue(OperationIdKey, out var operationId); var sender = TryGetMessageSender(message) ?? "Unknown sender"; var eventTimeUtc = message.SystemProperties.EnqueuedTimeUtc; var eventProcessingDelay = DateTime.UtcNow - eventTimeUtc; // Creating nested context with operationId as a guid. This helps to correlate operations on a worker and a master machines. context = CreateNestedContext(context, operationId?.ToString()); Tracer.Debug(context, $"{Tracer.Name}.ReceivedEvent: ProcessingDelay={eventProcessingDelay}, Sender={sender}, OpId={operationId}, SeqNo={message.SystemProperties.SequenceNumber}, EQT={eventTimeUtc}, Filter={eventFilter}, Size={message.Body.Count}."); Tracer.TrackMetric(context, EventProcessingDelayInSecondsMetricName, (long)eventProcessingDelay.TotalSeconds); counters[ReceivedMessagesTotalSize].Add(message.Body.Count); counters[ReceivedEventBatchCount].Increment(); if (!foundEventFilter || !string.Equals(eventFilter as string, _configuration.Epoch)) { counters[FilteredEvents].Increment(); filteredEvents++; continue; } // Deserializing a message IReadOnlyList <ContentLocationEventData> eventDatas; using (counters[Deserialization].Start()) { eventDatas = eventDataSerializer.DeserializeEvents(message); } counters[ReceivedEventsCount].Add(eventDatas.Count); // Dispatching deserialized events data using (counters[DispatchEvents].Start()) { foreach (var eventData in eventDatas) { // An event processor may fail to process the event, but we will save the sequence point anyway. await DispatchAsync(context, eventData, counters); } } } Counters.Append(counters); return(BoolResult.Success); }, counters[ProcessEvents]) .IgnoreFailure(); // The error is logged }
/// <exception cref="System.IO.IOException"/> protected internal virtual long GetCounter(Counters counters, string counterGroupName , string counterName) { return(counters.FindCounter(counterGroupName, counterName).GetValue()); }
/// <exception cref="System.Exception"/> public virtual int Run(string[] argv) { int exitCode = -1; if (argv.Length < 1) { DisplayUsage(string.Empty); return(exitCode); } // process arguments string cmd = argv[0]; string submitJobFile = null; string jobid = null; string taskid = null; string historyFile = null; string counterGroupName = null; string counterName = null; JobPriority jp = null; string taskType = null; string taskState = null; int fromEvent = 0; int nEvents = 0; bool getStatus = false; bool getCounter = false; bool killJob = false; bool listEvents = false; bool viewHistory = false; bool viewAllHistory = false; bool listJobs = false; bool listAllJobs = false; bool listActiveTrackers = false; bool listBlacklistedTrackers = false; bool displayTasks = false; bool killTask = false; bool failTask = false; bool setJobPriority = false; bool logs = false; if ("-submit".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } submitJobFile = argv[1]; } else { if ("-status".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; getStatus = true; } else { if ("-counter".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } getCounter = true; jobid = argv[1]; counterGroupName = argv[2]; counterName = argv[3]; } else { if ("-kill".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; killJob = true; } else { if ("-set-priority".Equals(cmd)) { if (argv.Length != 3) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; try { jp = JobPriority.ValueOf(argv[2]); } catch (ArgumentException iae) { Log.Info(iae); DisplayUsage(cmd); return(exitCode); } setJobPriority = true; } else { if ("-events".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; fromEvent = System.Convert.ToInt32(argv[2]); nEvents = System.Convert.ToInt32(argv[3]); listEvents = true; } else { if ("-history".Equals(cmd)) { if (argv.Length != 2 && !(argv.Length == 3 && "all".Equals(argv[1]))) { DisplayUsage(cmd); return(exitCode); } viewHistory = true; if (argv.Length == 3 && "all".Equals(argv[1])) { viewAllHistory = true; historyFile = argv[2]; } else { historyFile = argv[1]; } } else { if ("-list".Equals(cmd)) { if (argv.Length != 1 && !(argv.Length == 2 && "all".Equals(argv[1]))) { DisplayUsage(cmd); return(exitCode); } if (argv.Length == 2 && "all".Equals(argv[1])) { listAllJobs = true; } else { listJobs = true; } } else { if ("-kill-task".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } killTask = true; taskid = argv[1]; } else { if ("-fail-task".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } failTask = true; taskid = argv[1]; } else { if ("-list-active-trackers".Equals(cmd)) { if (argv.Length != 1) { DisplayUsage(cmd); return(exitCode); } listActiveTrackers = true; } else { if ("-list-blacklisted-trackers".Equals(cmd)) { if (argv.Length != 1) { DisplayUsage(cmd); return(exitCode); } listBlacklistedTrackers = true; } else { if ("-list-attempt-ids".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; taskType = argv[2]; taskState = argv[3]; displayTasks = true; if (!taskTypes.Contains(StringUtils.ToUpperCase(taskType))) { System.Console.Out.WriteLine("Error: Invalid task-type: " + taskType); DisplayUsage(cmd); return(exitCode); } if (!taskStates.Contains(StringUtils.ToLowerCase(taskState))) { System.Console.Out.WriteLine("Error: Invalid task-state: " + taskState); DisplayUsage(cmd); return(exitCode); } } else { if ("-logs".Equals(cmd)) { if (argv.Length == 2 || argv.Length == 3) { logs = true; jobid = argv[1]; if (argv.Length == 3) { taskid = argv[2]; } else { taskid = null; } } else { DisplayUsage(cmd); return(exitCode); } } else { DisplayUsage(cmd); return(exitCode); } } } } } } } } } } } } } } // initialize cluster cluster = CreateCluster(); // Submit the request try { if (submitJobFile != null) { Job job = Job.GetInstance(new JobConf(submitJobFile)); job.Submit(); System.Console.Out.WriteLine("Created job " + job.GetJobID()); exitCode = 0; } else { if (getStatus) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { Counters counters = job.GetCounters(); System.Console.Out.WriteLine(); System.Console.Out.WriteLine(job); if (counters != null) { System.Console.Out.WriteLine(counters); } else { System.Console.Out.WriteLine("Counters not available. Job is retired."); } exitCode = 0; } } else { if (getCounter) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { Counters counters = job.GetCounters(); if (counters == null) { System.Console.Out.WriteLine("Counters not available for retired job " + jobid); exitCode = -1; } else { System.Console.Out.WriteLine(GetCounter(counters, counterGroupName, counterName)); exitCode = 0; } } } else { if (killJob) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { JobStatus jobStatus = job.GetStatus(); if (jobStatus.GetState() == JobStatus.State.Failed) { System.Console.Out.WriteLine("Could not mark the job " + jobid + " as killed, as it has already failed." ); exitCode = -1; } else { if (jobStatus.GetState() == JobStatus.State.Killed) { System.Console.Out.WriteLine("The job " + jobid + " has already been killed."); exitCode = -1; } else { if (jobStatus.GetState() == JobStatus.State.Succeeded) { System.Console.Out.WriteLine("Could not kill the job " + jobid + ", as it has already succeeded." ); exitCode = -1; } else { job.KillJob(); System.Console.Out.WriteLine("Killed job " + jobid); exitCode = 0; } } } } } else { if (setJobPriority) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { job.SetPriority(jp); System.Console.Out.WriteLine("Changed job priority."); exitCode = 0; } } else { if (viewHistory) { ViewHistory(historyFile, viewAllHistory); exitCode = 0; } else { if (listEvents) { ListEvents(cluster.GetJob(JobID.ForName(jobid)), fromEvent, nEvents); exitCode = 0; } else { if (listJobs) { ListJobs(cluster); exitCode = 0; } else { if (listAllJobs) { ListAllJobs(cluster); exitCode = 0; } else { if (listActiveTrackers) { ListActiveTrackers(cluster); exitCode = 0; } else { if (listBlacklistedTrackers) { ListBlacklistedTrackers(cluster); exitCode = 0; } else { if (displayTasks) { DisplayTasks(cluster.GetJob(JobID.ForName(jobid)), taskType, taskState); exitCode = 0; } else { if (killTask) { TaskAttemptID taskID = TaskAttemptID.ForName(taskid); Job job = cluster.GetJob(taskID.GetJobID()); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { if (job.KillTask(taskID, false)) { System.Console.Out.WriteLine("Killed task " + taskid); exitCode = 0; } else { System.Console.Out.WriteLine("Could not kill task " + taskid); exitCode = -1; } } } else { if (failTask) { TaskAttemptID taskID = TaskAttemptID.ForName(taskid); Job job = cluster.GetJob(taskID.GetJobID()); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { if (job.KillTask(taskID, true)) { System.Console.Out.WriteLine("Killed task " + taskID + " by failing it"); exitCode = 0; } else { System.Console.Out.WriteLine("Could not fail task " + taskid); exitCode = -1; } } } else { if (logs) { try { JobID jobID = JobID.ForName(jobid); TaskAttemptID taskAttemptID = TaskAttemptID.ForName(taskid); LogParams logParams = cluster.GetLogParams(jobID, taskAttemptID); LogCLIHelpers logDumper = new LogCLIHelpers(); logDumper.SetConf(GetConf()); exitCode = logDumper.DumpAContainersLogs(logParams.GetApplicationId(), logParams. GetContainerId(), logParams.GetNodeId(), logParams.GetOwner()); } catch (IOException e) { if (e is RemoteException) { throw; } System.Console.Out.WriteLine(e.Message); } } } } } } } } } } } } } } } } } catch (RemoteException re) { IOException unwrappedException = re.UnwrapRemoteException(); if (unwrappedException is AccessControlException) { System.Console.Out.WriteLine(unwrappedException.Message); } else { throw; } } finally { cluster.Close(); } return(exitCode); }
public override void Execute() { AudioSource.PlayClipAtPoint(token.tokenCollectAudio, token.transform.position); Counters.Increment(Counters.CounterType.TokenCollect); }
private CallSequence(ILogFile log) { _counters = new Counters(); _log = log; _tail = null; }
public void CreateMissingCollections() { //if (!_mongoDatabase.CollectionExists(CollectionName)) // _mongoDatabase.CreateCollection(CollectionName); if (!_mongoDatabase.CollectionExists(UserOAuthProvider_Col)) _mongoDatabase.CreateCollection(UserOAuthProvider_Col); if (!_mongoDatabase.CollectionExists(typeof(Counters).Name)) { _mongoDatabase.CreateCollection(typeof(Counters).Name); var countersCollection = _mongoDatabase.GetCollection<Counters>(typeof(Counters).Name); Counters counters = new Counters(); countersCollection.Save(counters); } }
private IDisposable CreateCounters(IObserver<Counters> observer) { var disposable = new CompositeDisposable(); try { var processName = Process.GetCurrentProcess().ProcessName; var memoryCounter = new PerformanceCounter("Process", "Working Set - Private", processName); var cpuCounter = new PerformanceCounter("Process", "% Processor Time", processName); var counters = new Counters(memoryCounter, cpuCounter); observer.OnNext(counters); disposable.Add(counters); } catch (Exception exn) { observer.OnError(exn); } return disposable; }
/// <summary> /// Get the counter context matching the counter name. /// </summary> /// <param name="counterName">Counter name.</param> /// <returns>Counter context with the counter name.</returns> internal CounterContext GetCounterContextByName(string counterName) { return(Counters.First(_ => _.CounterName == counterName)); }
/// <summary><inheritDoc/></summary> public override void PrettyLog(Redwood.RedwoodChannels channels, string description) { PrettyLogger.Log(channels, description, Counters.AsMap(this)); }
private async Task ProcessingTaskAsync(RabbitMessage message) { if (message.Body == null) { return; } try { Core.Log.LibVerbose("Received {0} bytes from the Queue '{1}/{2}'", message.Body.Length, _receiver.Route, _receiver.Name); var messageBody = ReceiverSerializer.Deserialize(message.Body, _messageType); switch (messageBody) { case RequestMessage request when request.Header != null: request.Header.ApplicationReceivedTime = Core.Now; Counters.IncrementReceivingTime(request.Header.TotalTime); if (request.Header.ClientName != Config.Name) { Core.Log.Warning("The Message Client Name '{0}' is different from the Server Name '{1}'", request.Header.ClientName, Config.Name); } var evArgs = new RequestReceivedEventArgs(_name, _receiver, request, message.Body.Length) { Metadata = { ["ReplyTo"] = message.Properties.ReplyTo, ["MessageId"] = message.Properties.MessageId } }; if (request.Header.ResponseQueue != null) { evArgs.ResponseQueues.Add(request.Header.ResponseQueue); } await OnRequestReceivedAsync(evArgs).ConfigureAwait(false); break; case ResponseMessage response when response.Header != null: response.Header.Response.ApplicationReceivedTime = Core.Now; Counters.IncrementReceivingTime(response.Header.Response.TotalTime); var evArgs2 = new ResponseReceivedEventArgs(_name, response, message.Body.Length) { Metadata = { ["ReplyTo"] = message.Properties.ReplyTo, ["MessageId"] = message.Properties.MessageId } }; await OnResponseReceivedAsync(evArgs2).ConfigureAwait(false); break; } Counters.IncrementTotalMessagesProccesed(); } catch (Exception ex) { Counters.IncrementTotalExceptions(); Core.Log.Write(ex); lock (_lock) _exceptionSleep = true; } }
/// <summary>Print some statistics about this lexicon.</summary> public virtual void PrintLexStats() { System.Console.Out.WriteLine("BaseLexicon statistics"); System.Console.Out.WriteLine("unknownLevel is " + GetUnknownWordModel().GetUnknownLevel()); // System.out.println("Rules size: " + rules.size()); System.Console.Out.WriteLine("Sum of rulesWithWord: " + NumRules()); System.Console.Out.WriteLine("Tags size: " + tags.Count); int wsize = words.Count; System.Console.Out.WriteLine("Words size: " + wsize); // System.out.println("Unseen Sigs size: " + sigs.size() + // " [number of unknown equivalence classes]"); System.Console.Out.WriteLine("rulesWithWord length: " + rulesWithWord.Length + " [should be sum of words + unknown sigs]"); int[] lengths = new int[StatsBins]; List <string>[] wArr = new ArrayList[StatsBins]; for (int j = 0; j < StatsBins; j++) { wArr[j] = new List <string>(); } for (int i = 0; i < rulesWithWord.Length; i++) { int num = rulesWithWord[i].Count; if (num > StatsBins - 1) { num = StatsBins - 1; } lengths[num]++; if (wsize <= 20 || num >= StatsBins / 2) { wArr[num].Add(wordIndex.Get(i)); } } System.Console.Out.WriteLine("Stats on how many taggings for how many words"); for (int j_1 = 0; j_1 < StatsBins; j_1++) { System.Console.Out.Write(j_1 + " taggings: " + lengths[j_1] + " words "); if (wsize <= 20 || j_1 >= StatsBins / 2) { System.Console.Out.Write(wArr[j_1]); } System.Console.Out.WriteLine(); } NumberFormat nf = NumberFormat.GetNumberInstance(); nf.SetMaximumFractionDigits(0); System.Console.Out.WriteLine("Unseen counter: " + Counters.ToString(uwModel.UnSeenCounter(), nf)); if (wsize < 50 && tags.Count < 10) { nf.SetMaximumFractionDigits(3); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.Println("Tagging probabilities log P(word|tag)"); for (int t = 0; t < tags.Count; t++) { pw.Print('\t'); pw.Print(tagIndex.Get(t)); } pw.Println(); for (int w = 0; w < wsize; w++) { pw.Print(wordIndex.Get(w)); pw.Print('\t'); for (int t_1 = 0; t_1 < tags.Count; t_1++) { IntTaggedWord iTW = new IntTaggedWord(w, t_1); pw.Print(nf.Format(Score(iTW, 1, wordIndex.Get(w), null))); if (t_1 == tags.Count - 1) { pw.Println(); } else { pw.Print('\t'); } } } pw.Close(); System.Console.Out.WriteLine(sw.ToString()); } }
partial void InsertCounters(Counters instance);
/// <summary> /// Return various statistics about the treebank (number of sentences, /// words, tag set, etc.). /// </summary> /// <param name="tlp"> /// The TreebankLanguagePack used to determine punctuation and an /// appropriate character encoding /// </param> /// <returns>A big string for human consumption describing the treebank</returns> public virtual string TextualSummary(ITreebankLanguagePack tlp) { int numTrees = 0; int numTreesLE40 = 0; int numNonUnaryRoots = 0; Tree nonUnaryEg = null; ClassicCounter <Tree> nonUnaries = new ClassicCounter <Tree>(); ClassicCounter <string> roots = new ClassicCounter <string>(); ClassicCounter <string> starts = new ClassicCounter <string>(); ClassicCounter <string> puncts = new ClassicCounter <string>(); int numUnenclosedLeaves = 0; int numLeaves = 0; int numNonPhrasal = 0; int numPreTerminalWithMultipleChildren = 0; int numWords = 0; int numTags = 0; int shortestSentence = int.MaxValue; int longestSentence = 0; int numNullLabel = 0; ICollection <string> words = Generics.NewHashSet(); ClassicCounter <string> tags = new ClassicCounter <string>(); ClassicCounter <string> cats = new ClassicCounter <string>(); Tree leafEg = null; Tree preTerminalMultipleChildrenEg = null; Tree nullLabelEg = null; Tree rootRewritesAsTaggedWordEg = null; foreach (Tree t in this) { roots.IncrementCount(t.Value()); numTrees++; int leng = t.Yield().Count; if (leng <= 40) { numTreesLE40++; } if (leng < shortestSentence) { shortestSentence = leng; } if (leng > longestSentence) { longestSentence = leng; } if (t.NumChildren() > 1) { if (numNonUnaryRoots == 0) { nonUnaryEg = t; } if (numNonUnaryRoots < 100) { nonUnaries.IncrementCount(t.LocalTree()); } numNonUnaryRoots++; } else { if (t.IsLeaf()) { numUnenclosedLeaves++; } else { Tree t2 = t.FirstChild(); if (t2.IsLeaf()) { numLeaves++; leafEg = t; } else { if (t2.IsPreTerminal()) { if (numNonPhrasal == 0) { rootRewritesAsTaggedWordEg = t; } numNonPhrasal++; } } starts.IncrementCount(t2.Value()); } } foreach (Tree subtree in t) { ILabel lab = subtree.Label(); if (lab == null || lab.Value() == null || lab.Value().IsEmpty()) { if (numNullLabel == 0) { nullLabelEg = subtree; } numNullLabel++; if (lab == null) { subtree.SetLabel(new StringLabel(string.Empty)); } else { if (lab.Value() == null) { subtree.Label().SetValue(string.Empty); } } } if (subtree.IsLeaf()) { numWords++; words.Add(subtree.Value()); } else { if (subtree.IsPreTerminal()) { numTags++; tags.IncrementCount(subtree.Value()); if (tlp != null && tlp.IsPunctuationTag(subtree.Value())) { puncts.IncrementCount(subtree.FirstChild().Value()); } } else { if (subtree.IsPhrasal()) { bool hasLeafChild = false; foreach (Tree kt in subtree.Children()) { if (kt.IsLeaf()) { hasLeafChild = true; } } if (hasLeafChild) { numPreTerminalWithMultipleChildren++; if (preTerminalMultipleChildrenEg == null) { preTerminalMultipleChildrenEg = subtree; } } cats.IncrementCount(subtree.Value()); } else { throw new InvalidOperationException("Treebank: Bad tree in treebank!: " + subtree); } } } } } StringWriter sw = new StringWriter(2000); PrintWriter pw = new PrintWriter(sw); NumberFormat nf = NumberFormat.GetNumberInstance(); nf.SetMaximumFractionDigits(0); pw.Println("Treebank has " + numTrees + " trees (" + numTreesLE40 + " of length <= 40) and " + numWords + " words (tokens)"); if (numTrees > 0) { if (numTags != numWords) { pw.Println(" Warning! numTags differs and is " + numTags); } if (roots.Size() == 1) { string root = (string)Sharpen.Collections.ToArray(roots.KeySet())[0]; pw.Println(" The root category is: " + root); } else { pw.Println(" Warning! " + roots.Size() + " different roots in treebank: " + Counters.ToString(roots, nf)); } if (numNonUnaryRoots > 0) { pw.Print(" Warning! " + numNonUnaryRoots + " trees without unary initial rewrite. "); if (numNonUnaryRoots > 100) { pw.Print("First 100 "); } pw.Println("Rewrites: " + Counters.ToString(nonUnaries, nf)); pw.Println(" Example: " + nonUnaryEg); } if (numUnenclosedLeaves > 0 || numLeaves > 0 || numNonPhrasal > 0) { pw.Println(" Warning! Non-phrasal trees: " + numUnenclosedLeaves + " bare leaves; " + numLeaves + " root rewrites as leaf; and " + numNonPhrasal + " root rewrites as tagged word"); if (numLeaves > 0) { pw.Println(" Example bad root rewrites as leaf: " + leafEg); } if (numNonPhrasal > 0) { pw.Println(" Example bad root rewrites as tagged word: " + rootRewritesAsTaggedWordEg); } } if (numNullLabel > 0) { pw.Println(" Warning! " + numNullLabel + " tree nodes with null or empty string labels, e.g.:"); pw.Println(" " + nullLabelEg); } if (numPreTerminalWithMultipleChildren > 0) { pw.Println(" Warning! " + numPreTerminalWithMultipleChildren + " preterminal nodes with multiple children."); pw.Println(" Example: " + preTerminalMultipleChildrenEg); } pw.Println(" Sentences range from " + shortestSentence + " to " + longestSentence + " words, with an average length of " + (((numWords * 100) / numTrees) / 100.0) + " words."); pw.Println(" " + cats.Size() + " phrasal category types, " + tags.Size() + " tag types, and " + words.Count + " word types"); string[] empties = new string[] { "*", "0", "*T*", "*RNR*", "*U*", "*?*", "*EXP*", "*ICH*", "*NOT*", "*PPA*", "*OP*", "*pro*", "*PRO*" }; // What a dopey choice using 0 as an empty element name!! // The problem with the below is that words aren't turned into a basic // category, but empties commonly are indexed.... Would need to look // for them with a suffix of -[0-9]+ ICollection <string> knownEmpties = Generics.NewHashSet(Arrays.AsList(empties)); ICollection <string> emptiesIntersection = Sets.Intersection(words, knownEmpties); if (!emptiesIntersection.IsEmpty()) { pw.Println(" Caution! " + emptiesIntersection.Count + " word types are known empty elements: " + emptiesIntersection); } ICollection <string> joint = Sets.Intersection(cats.KeySet(), tags.KeySet()); if (!joint.IsEmpty()) { pw.Println(" Warning! " + joint.Count + " items are tags and categories: " + joint); } foreach (string cat in cats.KeySet()) { if (cat != null && cat.Contains("@")) { pw.Println(" Warning!! Stanford Parser does not work with categories containing '@' like: " + cat); break; } } foreach (string cat_1 in tags.KeySet()) { if (cat_1 != null && cat_1.Contains("@")) { pw.Println(" Warning!! Stanford Parser does not work with tags containing '@' like: " + cat_1); break; } } pw.Println(" Cats: " + Counters.ToString(cats, nf)); pw.Println(" Tags: " + Counters.ToString(tags, nf)); pw.Println(" " + starts.Size() + " start categories: " + Counters.ToString(starts, nf)); if (!puncts.IsEmpty()) { pw.Println(" Puncts: " + Counters.ToString(puncts, nf)); } } return(sw.ToString()); }
private AgentConnector(IIoC ioc) { _counters = new Counters(); _log = ioc.Resolve<ILogFile>(); }
private void HandleKextReport(AccessReport report) { if (ProcessInfo.FileAccessManifest.ReportFileAccesses) { LogProcessState("Kext report received: " + AccessReportToString(report)); } Counters.IncrementCounter(SandboxedProcessCounters.AccessReportCount); using (Counters.StartStopwatch(SandboxedProcessCounters.HandleAccessReportDuration)) { UpdateAverageTimeSpentInReportQueue(report.Statistics); // caching path existence checks would speed things up, but it would not be semantically sound w.r.t. our unit tests // TODO: check if the tests are overspecified because in practice BuildXL doesn't really rely much on the outcome of this check var reportPath = report.Path; // Set the process exit time once we receive it from the sandbox kernel extension report queue if (report.Operation == FileOperation.OpProcessExit && report.Pid == Process.Id) { m_processExitTimeNs = report.Statistics.EnqueueTime; } var pathExists = true; // special handling for MAC_LOOKUP: // - don't report for existent paths (because for those paths other reports will follow) // - otherwise, set report.RequestAccess to Probe (because the Sandbox reports 'Lookup', but hat BXL expects 'Probe'), if (report.Operation == FileOperation.OpMacLookup) { pathExists = FileUtilities.Exists(reportPath); if (pathExists) { return; } else { report.RequestedAccess = (uint)RequestedAccess.Probe; } } // special handling for directory rename: // - scenario: a pip writes a bunch of files into a directory (e.g., 'out.tmp') and then renames that directory (e.g., to 'out') // - up to this point we know about the writes into the 'out.tmp' directory // - once 'out.tmp' is renamed to 'out', we need to explicitly update all previously reported paths under 'out.tmp' // - since we cannot rewrite the past and directly mutate previously reported paths, we simply enumerate // the content of the renamed directory and report all the files in there as writes // - (this is exactly how this is done on Windows, except that it's implemented in the Detours layer) else if (report.Operation == FileOperation.OpKAuthMoveDest && report.Status == (uint)FileAccessStatus.Allowed && FileUtilities.DirectoryExistsNoFollow(reportPath)) { FileUtilities.EnumerateFiles( directoryPath: reportPath, recursive: true, pattern: "*", (dir, fileName, attrs, length) => { AccessReport reportClone = report; reportClone.Operation = FileOperation.OpKAuthWriteFile; reportClone.Path = Path.Combine(dir, fileName); ReportFileAccess(ref reportClone); }); } // our sandbox kernel extension currently doesn't detect file existence, so do it here instead if (report.Error == 0 && !pathExists) { report.Error = ReportedFileAccess.ERROR_PATH_NOT_FOUND; } if (report.Operation == FileOperation.OpProcessTreeCompleted) { m_pendingReports.Complete(); } else { ReportFileAccess(ref report); } } }
internal void EnterCounter(Counters counter) { #if GRIDPARANOIA if (_counters != null) { Debug.Assert((int)counter < _counters.Length); int i = (int)counter; QueryPerformanceCounter(out _counters[i].Start); } #endif // GRIDPARANOIA }
private MRProtos.CountersProto ConvertToProtoFormat(Counters t) { return(((CountersPBImpl)t).GetProto()); }
public override Method Merge(Method model) { Counters.Merge(model.Counters); return(this); }
private void PerformCacheMissAnalysis(Process pip, FingerprintStoreEntry oldEntry, FingerprintStoreEntry newEntry, bool fromCacheLookup) { Contract.Requires(pip != null); string pipDescription = pip.GetDescription(m_context); try { if (!m_pipCacheMissesDict.TryRemove(pip.PipId, out var missInfo)) { return; } MarkPipAsChanged(pip.PipId); if (fromCacheLookup) { Counters.IncrementCounter(FingerprintStoreCounters.CacheMissAnalysisAnalyzeCacheLookUpCount); } else { Counters.IncrementCounter(FingerprintStoreCounters.CacheMissAnalysisAnalyzeExecutionCount); } using (var pool = Pools.StringBuilderPool.GetInstance()) using (Counters.StartStopwatch(FingerprintStoreCounters.CacheMissAnalysisAnalyzeDuration)) { var resultAndDetail = CacheMissAnalysisUtilities.AnalyzeCacheMiss( missInfo, () => new FingerprintStoreReader.PipRecordingSession(PreviousFingerprintStore, oldEntry), () => new FingerprintStoreReader.PipRecordingSession(m_logTarget.ExecutionFingerprintStore, newEntry), CacheMissDiffFormat); pipDescription = pip.GetDescription(m_context); if (m_batchLoggingQueue != null) { Counters.IncrementCounter(FingerprintStoreCounters.CacheMissBatchingEnqueueCount); m_batchLoggingQueue.Enqueue(resultAndDetail.Detail.ToJObjectWithPipInfo(pip.FormattedSemiStableHash, pipDescription, fromCacheLookup)); } else { var detail = new JObject( new JProperty(nameof(resultAndDetail.Detail.ActualMissType), resultAndDetail.Detail.ActualMissType), new JProperty(nameof(resultAndDetail.Detail.ReasonFromAnalysis), resultAndDetail.Detail.ReasonFromAnalysis), new JProperty(nameof(resultAndDetail.Detail.Info), resultAndDetail.Detail.Info)).ToString(); Logger.Log.CacheMissAnalysis(m_loggingContext, pipDescription, detail, fromCacheLookup); } m_testHooks?.AddCacheMiss( pip.PipId, new FingerprintStoreTestHooks.CacheMissData { DetailAndResult = resultAndDetail, IsFromCacheLookUp = fromCacheLookup }); } } catch (Exception ex) { // Cache miss analysis shouldn't fail the build Logger.Log.CacheMissAnalysisException(m_loggingContext, pipDescription, ex.ToString(), oldEntry?.PipToFingerprintKeys.ToString(), newEntry?.PipToFingerprintKeys.ToString()); } }
public void Dispose() { HttpClient.Dispose(); Counters.Clear(); }
public MapAttemptFinishedEvent(TaskAttemptID id, TaskType taskType, string taskStatus , long mapFinishTime, long finishTime, string hostname, string state, Counters counters ) : this(id, taskType, taskStatus, mapFinishTime, finishTime, hostname, -1, string.Empty , state, counters, null) { }
public void Increment(Counters counter) { CounterHelper.Increment(counter); }
public static void Main(string[] args) { if (args.Length < minArgs) { System.Console.Out.WriteLine(usage); System.Environment.Exit(-1); } // Process command-line options Properties options = StringUtils.ArgsToProperties(args, optionArgDefinitions); string fileName = options.GetProperty(string.Empty); if (fileName == null || fileName.Equals(string.Empty)) { System.Console.Out.WriteLine(usage); System.Environment.Exit(-1); } Language language = PropertiesUtils.Get(options, "l", Language.English, typeof(Language)); ITreebankLangParserParams tlpp = language.@params; string encoding = options.GetProperty("e", "UTF-8"); tlpp.SetInputEncoding(encoding); tlpp.SetOutputEncoding(encoding); DiskTreebank tb = tlpp.DiskTreebank(); tb.LoadPath(fileName); // Statistics ICounter <string> binaryRuleTypes = new ClassicCounter <string>(20000); IList <int> branchingFactors = new List <int>(20000); int nTrees = 0; int nUnaryRules = 0; int nBinaryRules = 0; int binaryBranchingFactors = 0; // Read the treebank PrintWriter pw = tlpp.Pw(); foreach (Tree tree in tb) { if (tree.Value().Equals("ROOT")) { tree = tree.FirstChild(); } ++nTrees; foreach (Tree subTree in tree) { if (subTree.IsPhrasal()) { if (subTree.NumChildren() > 1) { ++nBinaryRules; branchingFactors.Add(subTree.NumChildren()); binaryBranchingFactors += subTree.NumChildren(); binaryRuleTypes.IncrementCount(TreeToRuleString(subTree)); } else { ++nUnaryRules; } } } } double mean = (double)binaryBranchingFactors / (double)nBinaryRules; System.Console.Out.Printf("#trees:\t%d%n", nTrees); System.Console.Out.Printf("#binary:\t%d%n", nBinaryRules); System.Console.Out.Printf("#binary types:\t%d%n", binaryRuleTypes.KeySet().Count); System.Console.Out.Printf("mean branching:\t%.4f%n", mean); System.Console.Out.Printf("stddev branching:\t%.4f%n", StandardDeviation(branchingFactors, mean)); System.Console.Out.Printf("rule entropy:\t%.5f%n", Counters.Entropy(binaryRuleTypes)); System.Console.Out.Printf("#unaries:\t%d%n", nUnaryRules); }
public Aggregator(IHostEnvironment env, IRegressionLoss lossFunction, bool weighted, string stratName) : base(env, lossFunction, weighted, stratName) { _counters = new Counters(); _weightedCounters = Weighted ? new Counters() : null; }
internal override void OnSceneChanging() { Flags.Clear(); Counters.Clear(); Timers.Clear(); }
public virtual void Display(bool displayWords, bool displayOOV) { NumberFormat nf = new DecimalFormat("0.00"); System.Console.Out.WriteLine("======================================================"); System.Console.Out.WriteLine(">>> " + corpusName); System.Console.Out.WriteLine(" trees:\t\t" + numTrees); System.Console.Out.WriteLine(" words:\t\t" + words.KeySet().Count); System.Console.Out.WriteLine(" tokens:\t" + (int)words.TotalCount()); System.Console.Out.WriteLine(" tags:\t\t" + posTags.Size()); System.Console.Out.WriteLine(" phrasal types:\t" + phrasalBranchingNum2.KeySet().Count); System.Console.Out.WriteLine(" phrasal nodes:\t" + (int)phrasalBranchingNum2.TotalCount()); System.Console.Out.WriteLine(" OOV rate:\t" + nf.Format(OOVRate * 100.0) + "%"); System.Console.Out.WriteLine("======================================================"); System.Console.Out.WriteLine(">>> Per tree means"); System.Console.Out.Printf(" depth:\t\t%s\t{min:%d\tmax:%d}\t\ts: %s\n", nf.Format(meanDepth), minDepth, maxDepth, nf.Format(stddevDepth)); System.Console.Out.Printf(" breadth:\t%s\t{min:%d\tmax:%d}\ts: %s\n", nf.Format(meanBreadth), minBreadth, maxBreadth, nf.Format(stddevBreadth)); System.Console.Out.Printf(" length:\t%s\t{min:%d\tmax:%d}\ts: %s\n", nf.Format(meanLength), minLength, maxLength, nf.Format(stddevLength)); System.Console.Out.WriteLine(" branching:\t" + nf.Format(meanBranchingFactor)); System.Console.Out.WriteLine(" constituents:\t" + nf.Format(meanConstituents)); System.Console.Out.WriteLine("======================================================"); System.Console.Out.WriteLine(">>> Branching factor means by phrasal tag:"); IList <string> sortedKeys = new List <string>(meanBranchingByLabel.KeySet()); sortedKeys.Sort(Counters.ToComparator(phrasalBranchingNum2, false, true)); foreach (string label in sortedKeys) { System.Console.Out.Printf(" %s:\t\t%s / %d instances\n", label, nf.Format(meanBranchingByLabel.GetCount(label)), (int)phrasalBranchingNum2.GetCount(label)); } System.Console.Out.WriteLine("======================================================"); System.Console.Out.WriteLine(">>> Phrasal tag counts"); sortedKeys = new List <string>(phrasalBranchingNum2.KeySet()); sortedKeys.Sort(Counters.ToComparator(phrasalBranchingNum2, false, true)); foreach (string label_1 in sortedKeys) { System.Console.Out.WriteLine(" " + label_1 + ":\t\t" + (int)phrasalBranchingNum2.GetCount(label_1)); } System.Console.Out.WriteLine("======================================================"); System.Console.Out.WriteLine(">>> POS tag counts"); sortedKeys = new List <string>(posTags.KeySet()); sortedKeys.Sort(Counters.ToComparator(posTags, false, true)); foreach (string posTag in sortedKeys) { System.Console.Out.WriteLine(" " + posTag + ":\t\t" + (int)posTags.GetCount(posTag)); } System.Console.Out.WriteLine("======================================================"); if (displayWords) { System.Console.Out.WriteLine(">>> Word counts"); sortedKeys = new List <string>(words.KeySet()); sortedKeys.Sort(Counters.ToComparator(words, false, true)); foreach (string word in sortedKeys) { System.Console.Out.WriteLine(" " + word + ":\t\t" + (int)words.GetCount(word)); } System.Console.Out.WriteLine("======================================================"); } if (displayOOV) { System.Console.Out.WriteLine(">>> OOV word types"); foreach (string word in oovWords) { System.Console.Out.WriteLine(" " + word); } System.Console.Out.WriteLine("======================================================"); } }
/// <summary> /// Runs the Viterbi algorithm on the sequence model /// in order to find the best sequence. /// </summary> /// <remarks> /// Runs the Viterbi algorithm on the sequence model /// in order to find the best sequence. /// This sequence finder only works on SequenceModel's with rightWindow == 0. /// </remarks> /// <returns>An array containing the int tags of the best sequence</returns> public virtual int[] BestSequence(ISequenceModel ts) { return(Counters.Argmax(KBestSequences(ts, 1))); }
public string[] GetCounterStats() { return(Counters.CounterReport()); }
private async Task ProcessingTaskAsync(byte[] data) { if (data == null) { return; } var oldContext = Core.ContextGroupName; try { (var body, var correlationId) = NSQueueClient.GetFromMessageBody(data); Counters.IncrementTotalReceivingBytes(body.Count); Core.Log.LibVerbose("Received {0} bytes from the Queue '{1}/{2}'", body.Count, Connection.Route, Connection.Name); var messageBody = ReceiverSerializer.Deserialize(body, _messageType); switch (messageBody) { case RequestMessage request when request.Header != null: if (!string.IsNullOrEmpty(request.Header.ContextGroupName)) { Core.ContextGroupName = request.Header.ContextGroupName; } request.Header.ApplicationReceivedTime = Core.Now; Counters.IncrementReceivingTime(request.Header.TotalTime); if (request.Header.ClientName != Config.Name) { Core.Log.Warning("The Message Client Name '{0}' is different from the Server Name '{1}'", request.Header.ClientName, Config.Name); } var evArgs = new RequestReceivedEventArgs(_name, Connection, request, body.Count, SenderSerializer, Config.RequestOptions.ServerReceiverOptions.CancellationBeforeClientResponseTimeoutInSec); if (request.Header.ResponseQueue != null) { evArgs.ResponseQueues.Add(request.Header.ResponseQueue); } await OnRequestReceivedAsync(evArgs).ConfigureAwait(false); break; case ResponseMessage response when response.Header != null: if (!string.IsNullOrEmpty(response.Header.Request.Header.ContextGroupName)) { Core.ContextGroupName = response.Header.Request.Header.ContextGroupName; } response.Header.Response.ApplicationReceivedTime = Core.Now; Counters.IncrementReceivingTime(response.Header.Response.TotalTime); var evArgs2 = new ResponseReceivedEventArgs(_name, response, body.Count); await OnResponseReceivedAsync(evArgs2).ConfigureAwait(false); break; } Counters.IncrementTotalMessagesProccesed(); } catch (Exception ex) { Counters.IncrementTotalExceptions(); Core.Log.Write(ex); Interlocked.Exchange(ref _exceptionSleep, 1); } finally { Core.ContextGroupName = oldContext; } }
public long GetEvaluationsCount(EvaluationStatus status) { return((Counters == null || !Counters.ContainsKey(status)) ? 0 : Counters[status]); }
public void Refresh() { try { Counters<Item> itemPreferenceCounts = new Counters<Item>(); lock (this) { int numUsers = 0; foreach (User user in dataModel.GetUsers()) { Preference[] prefs = user.GetPreferencesAsArray(); foreach (Preference preference in prefs) { itemPreferenceCounts.Increment(preference.Item); } numUsers++; } Dictionary<Item, double> newIufFactors = new Dictionary<Item, double>(1 + (4 * itemPreferenceCounts.Count) / 3); double logFactor = Math.Log(logBase); foreach (KeyValuePair<Item, MutableInteger> entry in itemPreferenceCounts.Map) { int count = entry.Value.Value; newIufFactors.Add(entry.Key, Math.Log((double) numUsers / (double) count) / logFactor); } iufFactors.Set(newIufFactors /* readonly */); } } catch (TasteException dme) { log.Warn( "Unable to refresh", dme); } }
private void detach_Counters(Counters entity) { this.SendPropertyChanging(); entity.Facility = null; }
public TimeCounter(int counterId, Counters counters) { _counter = counters.GetCounter(counterId); _ticks = 0; }
partial void UpdateCounters(Counters instance);
private async Task ProcessingTaskAsync(RabbitMessage message) { if (message.Body is null) { RabbitMessage.Return(message); return; } var oldContext = Core.ContextGroupName; try { Counters.IncrementTotalReceivingBytes(message.Body.Length); Core.Log.LibVerbose("Received {0} bytes from the Queue '{1}/{2}'", message.Body.Length, _receiver.Route, _receiver.Name); var messageBody = ReceiverSerializer.Deserialize(message.Body, _messageType); switch (messageBody) { case RequestMessage request when request.Header != null: if (!string.IsNullOrEmpty(request.Header.ContextGroupName)) { Core.ContextGroupName = request.Header.ContextGroupName; } request.Header.ApplicationReceivedTime = Core.Now; Counters.IncrementReceivingTime(request.Header.TotalTime); if (request.Header.ClientName != Config.Name) { Core.Log.Warning("The Message Client Name '{0}' is different from the Server Name '{1}'", request.Header.ClientName, Config.Name); } var evArgs = new RequestReceivedEventArgs(_name, _receiver, request, message.Body.Length, SenderSerializer, Config.RequestOptions.ServerReceiverOptions.CancellationBeforeClientResponseTimeoutInSec); evArgs.Metadata["ReplyTo"] = message.Properties.ReplyTo; evArgs.Metadata["MessageId"] = message.Properties.MessageId; if (request.Header.ResponseQueue != null) { evArgs.ResponseQueues.Add(request.Header.ResponseQueue); } await OnRequestReceivedAsync(evArgs).ConfigureAwait(false); break; case ResponseMessage response when response.Header != null: if (!string.IsNullOrEmpty(response.Header.Request.Header.ContextGroupName)) { Core.ContextGroupName = response.Header.Request.Header.ContextGroupName; } response.Header.Response.ApplicationReceivedTime = Core.Now; Counters.IncrementReceivingTime(response.Header.Response.TotalTime); var evArgs2 = new ResponseReceivedEventArgs(_name, response, message.Body.Length); evArgs2.Metadata["ReplyTo"] = message.Properties.ReplyTo; evArgs2.Metadata["MessageId"] = message.Properties.MessageId; await OnResponseReceivedAsync(evArgs2).ConfigureAwait(false); break; } Counters.IncrementTotalMessagesProccesed(); } catch (Exception ex) { Counters.IncrementTotalExceptions(); Core.Log.Write(ex); Interlocked.Exchange(ref _exceptionSleep, 1); } finally { Core.ContextGroupName = oldContext; RabbitMessage.Return(message); } }
internal void EnterCounterScope(Counters scopeCounter) { #if GRIDPARANOIA if (ID == "CountThis") { if (_counters == null) { _counters = new Counter[(int)Counters.Count]; } ExitCounterScope(Counters.Default); EnterCounter(scopeCounter); } else { _counters = null; } #endif // GRIDPARANOIA }
internal void ExitCounterScope(Counters scopeCounter) { #if GRIDPARANOIA if (_counters != null) { if (scopeCounter != Counters.Default) { ExitCounter(scopeCounter); } if (_hasNewCounterInfo) { string NFormat = "F6"; Console.WriteLine( "\ncounter name | total t (ms) | # of calls | per call t (ms)" + "\n----------------------+---------------+---------------+----------------------" ); for (int i = 0; i < _counters.Length; ++i) { if (_counters[i].Calls > 0) { Counters counter = (Counters)i; double total = CostInMilliseconds(_counters[i].Total); double single = total / _counters[i].Calls; string counterName = counter.ToString(); string separator; if (counterName.Length < 8) { separator = "\t\t\t"; } else if (counterName.Length < 16) { separator = "\t\t"; } else { separator = "\t"; } Console.WriteLine( counter.ToString() + separator + total.ToString(NFormat) + "\t" + _counters[i].Calls + "\t\t" + single.ToString(NFormat)); _counters[i] = new Counter(); } } } _hasNewCounterInfo = false; } #endif // GRIDPARANOIA }
public override void HandleOrder(OrderEventArgs args) { base.HandleOrder(args); if (args.Handled) { return; } var source = args.Source; var order = args.Order; /* example: deposit */ /* example: deposit (amount) */ if (_deposit.TryGetMatch(order, out var depositMatch)) { args.Handled = true; if (AtCounter(source, out var counter)) { var segment = Segment; var gold = segment.GetItemsAt(counter).OfType <Gold>().ToList(); if (gold.Any()) { var depositAmount = (uint)gold.Sum(g => g.Amount); if (depositMatch.Groups[1].Success && long.TryParse(depositMatch.Groups[1].Value, out var requestedAmount)) { if (requestedAmount <= 0 || requestedAmount > UInt32.MaxValue || requestedAmount > depositAmount) { SayTo(source, 6300243); /* Are you trying to be funny? */ return; } depositAmount = (uint)requestedAmount; } if (!ConsumeFromLocation <Gold>(counter, depositAmount)) { return; } source.Gold += depositAmount; SayTo(source, 6300256, source.Gold.ToString()); /* Thank you. Your balance is now {0} coins. */ } else { if (Counters.Any()) { SayTo(source, 6300246); /* Please put some coins on the counter. */ } else { SayTo(source, 6300247); /* Please put some coins on the ground. */ } } } else { if (_counters.Any()) { SayTo(source, 6300236); /* Please step up to a counter. */ } else { SayTo(source, 6300237); /* Please stand closer to me. */ } } return; } /* example: withdraw (amount) */ if (_withdraw.TryGetMatch(order, out var withdrawMatch)) { args.Handled = true; if (AtCounter(source, out var counter)) { if (withdrawMatch.Groups[1].Success && long.TryParse(withdrawMatch.Groups[1].Value, out var requestedAmount)) { if (requestedAmount <= 0 || requestedAmount > UInt32.MaxValue) { SayTo(source, 6300243); /* Are you trying to be funny? */ } else if (requestedAmount <= source.Gold) { source.Gold -= (uint)requestedAmount; var gold = new Gold() { Amount = (uint)requestedAmount }; gold.Move(counter, true, Segment); } else { SayTo(source, 6300258); /* You don't have that much in your account. */ } } else { SayTo(source, 6300257); /* Would you tell me the amount? */ } } else { if (_counters.Any()) { SayTo(source, 6300236); /* Please step up to a counter. */ } else { SayTo(source, 6300237); /* Please stand closer to me. */ } } return; } /* example: show balance */ if (_showBalance.TryGetMatch(order, out var showBalanceMatch)) { args.Handled = true; var balance = source.Gold; if (balance > 0) { SayTo(source, 6300260, balance.ToString()); /* Your account balance is {0} coins. */ } else { SayTo(source, 6300259); /* Your account is empty. */ } return; } }
private LocalDispatcher(IIoC ioc) { _counters = new Counters(); _log = ioc.Resolve<ILogFile>(); _lrepo = ioc.Resolve<ILocalRepo>(); }
/// <summary> /// Processes the hyper links. /// </summary> /// <param name = "crawlRequest">The crawl request.</param> /// <param name = "arachnodeDAO">The arachnode DAO.</param> public override void ProcessHyperLinks(CrawlRequest <TArachnodeDAO> crawlRequest, IArachnodeDAO arachnodeDAO) { if (ApplicationSettings.AssignHyperLinkDiscoveries) { _discoveryManager.AssignHyperLinkDiscoveries(crawlRequest, arachnodeDAO); } foreach (Discovery <TArachnodeDAO> hyperLinkDiscovery in crawlRequest.Discoveries.HyperLinks.Values) { if (!hyperLinkDiscovery.IsDisallowed) { if (hyperLinkDiscovery.DiscoveryState == DiscoveryState.Undiscovered) { if (crawlRequest.CurrentDepth < crawlRequest.MaximumDepth) { if (!_discoveryManager.IsCrawlRestricted(crawlRequest, hyperLinkDiscovery.Uri.AbsoluteUri)) { _cache.AddCrawlRequestToBeCrawled(new CrawlRequest <TArachnodeDAO>(crawlRequest, hyperLinkDiscovery, crawlRequest.CurrentDepth + 1, crawlRequest.MaximumDepth, crawlRequest.RestrictCrawlTo, crawlRequest.RestrictDiscoveriesTo, crawlRequest.Priority + hyperLinkDiscovery.PriorityBoost, crawlRequest.RenderTypeForChildren, crawlRequest.RenderTypeForChildren), false, false, arachnodeDAO); } } if (ApplicationSettings.InsertHyperLinks && hyperLinkDiscovery.IsStorable) { arachnodeDAO.InsertHyperLink(crawlRequest.Discovery.Uri.AbsoluteUri, hyperLinkDiscovery.Uri.AbsoluteUri, ApplicationSettings.ClassifyAbsoluteUris); } _consoleManager.OutputHyperLinkDiscovered(crawlRequest.Crawl.CrawlInfo.ThreadNumber, crawlRequest, hyperLinkDiscovery); } else { if (ApplicationSettings.InsertHyperLinkDiscoveries && hyperLinkDiscovery.IsStorable) { arachnodeDAO.InsertHyperLinkDiscovery(crawlRequest.Discovery.Uri.AbsoluteUri, hyperLinkDiscovery.Uri.AbsoluteUri); } _consoleManager.OutputCacheHit(crawlRequest.Crawl.CrawlInfo, crawlRequest, hyperLinkDiscovery); } } else { if (ApplicationSettings.InsertDisallowedAbsoluteUris) { if (hyperLinkDiscovery.DiscoveryState == DiscoveryState.Undiscovered) { arachnodeDAO.InsertDisallowedAbsoluteUri(crawlRequest.DataType.ContentTypeID, (int)crawlRequest.DataType.DiscoveryType, crawlRequest.Discovery.Uri.AbsoluteUri, hyperLinkDiscovery.Uri.AbsoluteUri, hyperLinkDiscovery.IsDisallowedReason, ApplicationSettings.ClassifyAbsoluteUris); } else { if (ApplicationSettings.InsertDisallowedAbsoluteUriDiscoveries) { arachnodeDAO.InsertDisallowedAbsoluteUriDiscovery(crawlRequest.Discovery.Uri.AbsoluteUri, hyperLinkDiscovery.Uri.AbsoluteUri); } } } _consoleManager.OutputIsDisallowedReason(crawlRequest.Crawl.CrawlInfo, crawlRequest, hyperLinkDiscovery); } } Counters.GetInstance().HyperLinksDiscovered(crawlRequest.Discoveries.HyperLinks.Count); }
public TimeCounter(string name, string notes, Counters counters) { int id = counters.FindId(name, notes); _counter = counters.GetCounter(id); _ticks = 0; }