Example #1
0
        static Engine()
        {
            Configuration = EngineConfiguration.Open();
            MediaFile.MCIErrorsThrowExceptions = Configuration.Settings.MCIErrorsThrowExceptions;
            _startTick           = HighResTimer.GetCurrentTickCount();
            _lastCPSSamplingTick = _startTick;
            Keyboard.DefaultTicksBetweenKeyEvents = (long)(Configuration.Settings.TimeBetweenKeyboardEvents * (double)HighResTimer.TicksPerSecond);

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            // deserialize all EngineState files listed in configuration
            if (Configuration.StateFiles != null && Configuration.StateFiles.LoadAtStartup == true)
            {
                foreach (var stateFile in Configuration.StateFiles)
                {
                    if (stateFile.LoadAtStartup == true)
                    {
                        LoadEngineStateFile(stateFile.Path, stateFile.IsBinary);
                    }
                }
            }

            VisibleSurfaces.ForcedRefreshRate = Configuration.Settings.VisibleSurfaceRefreshTimer;
            Application.Idle += Application_Idle;
        }
Example #2
0
        public frmSteeringDemo()
        {
            InitializeComponent();

            mFont = new Font("Arial", 10);

            mHighResTimer = new HighResTimer();

            mFormsTimer          = new System.Windows.Forms.Timer();
            mFormsTimer.Interval = 30; // 100 milliseconds is a tenth of a second
            mFormsTimer.Tick    += new System.EventHandler(this.TimerEventProcessor);

            pnlViewPort.MouseClick  += new MouseEventHandler(On_pnlViewPort_Click);
            pnlViewPort.SizeChanged += new EventHandler(On_pnlViewPort_Size);

            cmboChaseMode.SelectedIndex = 0;

            chkWalls.CheckedChanged            += new EventHandler(chkWalls_CheckedChanged);
            chkObstacles.CheckedChanged        += new EventHandler(chkObstacles_CheckedChanged);
            chkRenderAides.CheckedChanged      += new EventHandler(chkRenderAides_CheckedChanged);
            chkSpacePart.CheckedChanged        += new EventHandler(chkSpacePart_CheckedChanged);
            chkPenetrate.CheckedChanged        += new EventHandler(chkPenetrate_CheckedChanged);
            cmboChaseMode.SelectedIndexChanged += new EventHandler(cmboChaseMode_SelectedIndexChanged);
            cmboSamples.SelectedIndexChanged   += new EventHandler(cmboSamples_SelectedIndexChanged);
            cmboUpdate.SelectedIndexChanged    += new EventHandler(cmboUpdate_SelectedIndexChanged);
            spinMaxForce.ValueChanged          += new EventHandler(spinMaxForce_ValueChanged);
            spinMaxSpeed.ValueChanged          += new EventHandler(spinMaxSpeed_ValueChanged);
            spinAlignment.ValueChanged         += new EventHandler(spinAlignment_ValueChanged);
            spinCohesion.ValueChanged          += new EventHandler(spinCohesion_ValueChanged);
            spinSeparation.ValueChanged        += new EventHandler(spinSeparation_ValueChanged);
        }
Example #3
0
        public string SaveToFile()
        {
            string file = Environment.CurrentDirectory + @"\" + this.Name + "_"
                          + HighResTimer.GetCurrentTickCount().ToString() + ".bmp";

            return(SaveToFile(file));
        }
Example #4
0
        public void Put(Stream stream, string blobId)
        {
            // Use BlockBlob to store media assets
            // If blob with such Id already exists, it will be overwritten
            var blob = BlobContainer.GetBlockBlobReference(blobId);

            // Set blob streaming chunks if file larger than value specified in SingleBlobUploadThresholdInBytes setting.
            var streamWriteSizeBytes = Configuration.Settings.Media.AzureBlobStorage.StreamWriteSizeInBytes;

            if (streamWriteSizeBytes.HasValue && streamWriteSizeBytes.Value > 0)
            {
                blob.StreamWriteSizeInBytes = streamWriteSizeBytes.Value;
            }

            var requestProperties = GetRequestProperties();
            var timer             = new HighResTimer(true);

            //SqlServer SetBlobStream method deletes existing blob before inserting, does UploadFromStream overwrite existing blob?
            blob.UploadFromStream(stream, options: requestProperties.Item1, operationContext: requestProperties.Item2);
            timer.Stop();
            LogHelper.LogDebugInfo($"Upload of blob {blobId} of size {stream.Length} took {timer.ElapsedTimeSpan.ToString(Configuration.Constants.TimeSpanDebugFormat)}");

#if DEBUG
            var requestsInfo = new System.Text.StringBuilder();
            foreach (var request in requestProperties.Item2.RequestResults)
            {
                requestsInfo.AppendLine($"{request.ServiceRequestID} - {request.HttpStatusCode} - {request.HttpStatusMessage} - bytes: {request.EgressBytes}");
            }
            Log.Info($"operationContext.RequestResults: {requestsInfo}", this);
#endif
        }
Example #5
0
        public void Start()
        {
            // don't do anything if there is not a current movePoint
            if (_movePoint == null)
            {
                return;
            }

            // ignore if Sprite already moving
            if (Tile.TilesMoving.IndexOf(_parent) != -1)
            {
                return;
            }

            // reset velocities since using MovePoints
            _velocityX = 0;
            _velocityY = 0;

            // add Sprite to moving list
            Tile.TilesMoving.Add(_parent);

            _lastTick = HighResTimer.GetCurrentTickCount();

            // initialize MovePoint values based on Sprite's current state
            _movePoint.InitializeMovePoint();

            // raise the event
            if (Started != null)
            {
                Started(new SpriteMovementEventArgs(_parent, this));
            }
        }
Example #6
0
        public LuceneSearchResultCollection FieldSearch(QueryInfo[] qis)
        {
            HighResTimer timer        = new HighResTimer(true);
            var          booleanQuery = new BooleanQuery();

            foreach (var qi in qis)
            {
                var q = GetQuery(qi);
                if (q != null)
                {
                    booleanQuery.Add(q, qi.LuceneBooleanClauseOccur);
                }
            }

            IList <Document> hits = null;

            if (booleanQuery.Clauses.Count > 0)
            {
                hits = GetSearchHits(booleanQuery);
            }

            return(hits != null
                    ? new LuceneSearchResultCollection(hits, timer.Elapsed())
                    : null);
        }
Example #7
0
        public frmMinerDemo()
        {
            InitializeComponent();

            mHighResTimer = new HighResTimer();

            // m_AsyncWorker will be used to perform the AI work on a background thread.
            m_AsyncWorker = new BackgroundWorker();
            m_AsyncWorker.WorkerReportsProgress = true;
            m_AsyncWorker.ProgressChanged      += new ProgressChangedEventHandler(Thread_ProgressChanged);
            m_AsyncWorker.DoWork += new DoWorkEventHandler(Thread_DoWork);
            m_AsyncWorker.WorkerSupportsCancellation = true;

            // Just direct all debug output to our Message Writer
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new TextWriterTraceListener(DebugMessages.Instance));

            groupBox1.ForeColor = mColourBob;
            groupBox2.ForeColor = mColourElsa;
            groupBox3.ForeColor = mColourBarFly;

            //create a miner
            Bob = new Miner((int)EntityName.ent_Miner_Bob);

            //create his wife
            Elsa = new MinersWife((int)EntityName.ent_Elsa);

            Joe = new BarFlyJoe((int)EntityName.ent_BarFly);

            //register them with the Message Dispatcher
            MessageDispatcher.Instance.RegisterEntity(Bob);
            MessageDispatcher.Instance.RegisterEntity(Elsa);
            MessageDispatcher.Instance.RegisterEntity(Joe);
        }
Example #8
0
        public SitecoreSearchResultCollection FieldSearch(QueryInfo[] qis, int maxResults)
        {
            HighResTimer timer         = new HighResTimer(true);
            var          combinedQuery = new CombinedQuery();

            foreach (var qi in qis)
            {
                var q = GetQuery(qi);
                if (q != null)
                {
                    combinedQuery.Add(q, qi.SitecoreSearchQueryOccurance);
                }
            }

            SearchResultCollection results = null;

            if (combinedQuery.Clauses.Count > 0)
            {
                results = GetSearchHits(combinedQuery, maxResults);
            }

            return(results != null
                    ? new SitecoreSearchResultCollection(results, timer.Elapsed())
                    : null);
        }
Example #9
0
        public static Timer Add(string timerID, TimerType timerType, TimerCycles timerCycles, double timerLength)
        {
            Timer timer = new Timer(timerType, timerCycles, HighResTimer.GetCurrentTickCount(), timerLength);

            _timers.Add(timerID, timer);
            timer.TimerID = timerID;
            return(timer);
        }
Example #10
0
 protected internal Movement(Sprite sprite)
 {
     _parent        = sprite;
     _lastTick      = HighResTimer.GetCurrentTickCount();
     _velocityX     = 0;
     _velocityY     = 0;
     _accelerationX = 0;
     _accelerationY = 0;
 }
Example #11
0
 internal Movement(DirectDrawing drawing, double totalTime, Rectangle dest)
 {
     parent      = drawing;
     startTick   = HighResTimer.GetCurrentTickCount();
     lastTick    = startTick;
     totalTicks  = (long)(totalTime * (double)HighResTimer.TicksPerSecond);
     startBounds = parent.Bounds;
     destBounds  = dest;
 }
Example #12
0
 public FPSCounter(int totalSamples)
 {
     times = new long[totalSamples];
     for (int x = 0; x < times.Length; x++)
     {
         times[x] = 1;
     }
     m_currentSample = 0;
     m_totalFrames   = 0;
     HighResTimer.QueryPerformanceFrequency(ref m_tickFrequency);
 }
Example #13
0
            internal void Start(double totalTime, PointF dest)
            {
                Stop();

                startTick = HighResTimer.GetCurrentTickCount();
                //lastTick = startTick;
                totalTicks = (long)(totalTime * HighResTimer.TicksPerSecond);
                startCoord = parent.SourceGridPoint;
                destCoord  = dest;

                IsScrolling = true;
            }
Example #14
0
        public CrmProfiler(string methodName)
        {
            lock (Counters)
            {
                if (!Counters.ContainsKey(methodName))
                {
                    Counters.Add(methodName, new CrmProfilerCounter(methodName));
                }
            }

            this.methodName = methodName;
            this.timer      = new HighResTimer(true);
        }
Example #15
0
        public string Execute([NotNull] string path, [NotNull] string databaseName, [NotNull] string expression, [NotNull] string mode)
        {
            Assert.ArgumentNotNull(path, nameof(path));
            Assert.ArgumentNotNull(databaseName, nameof(databaseName));
            Assert.ArgumentNotNull(expression, nameof(expression));
            Assert.ArgumentNotNull(mode, nameof(mode));

            var database = Factory.GetDatabase(databaseName);

            if (database == null)
            {
                return("Database not found");
            }

            var currentItem = database.GetItem(path);

            if (currentItem == null)
            {
                return("Item not found");
            }

            try
            {
                IEnumerable <Item> items;

                var timer = new HighResTimer(true);

                if (mode == "real")
                {
                    items = EvaluateRealXPath(currentItem, expression);
                }
                else
                {
                    items = EvaluateSitecoreXPath(currentItem, expression);
                }

                var elapsed = timer.Elapsed();

                if (items == null)
                {
                    return(string.Empty);
                }

                return(FormatItems(items, elapsed));
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Example #16
0
        public void Get(Stream target, string blobId)
        {
            var blob = GetBlobReference(blobId);

            if (blob.Exists())
            {
                var requestProperties = GetRequestProperties();
                var timer             = new HighResTimer(true);
                blob.DownloadToStream(target: target, options: requestProperties.Item1,
                                      operationContext: requestProperties.Item2);
                timer.Stop();
                LogHelper.LogDebugInfo(
                    $"Download of blob with Id {blobId} of size {target.Length} took {timer.ElapsedTimeSpan.ToString(Configuration.Constants.TimeSpanDebugFormat)}");
            }
        }
Example #17
0
        //----------------------------------------------------------------------------------
        /// <summary>
        /// Search the index for a document where the field has the searchstring
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="searchString">The search string.</param>
        /// <param name="queryType">Type of the query.</param>
        /// <returns></returns>
        /// <remark>Created 07/01/2009 14:19 by jm</remark>
        //----------------------------------------------------------------------------------
        public SearchResultCollection FieldSearch(string fieldName, string searchString, string queryType)
        {
            if (String.IsNullOrEmpty(searchString) ||
                String.IsNullOrEmpty(fieldName) ||
                Index == null)
            {
                return null;
            }

            HighResTimer timer = new HighResTimer(true);
            Hits hits = GetSearchHits(fieldName, searchString, queryType);

            return hits != null
                    ? new SearchResultCollection(hits, timer.Elapsed())
                    : null;
        }
Example #18
0
        /// <summary>
        /// Processes the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(GetModelArgs args)
        {
            if (args.Rendering.Item == null ||
                args.Result == null ||
                args.Result is RenderingModel)
            {
                return;
            }
            HighResTimer timer = new HighResTimer(true);

            args.Rendering.Item.Project(args.Result);

            var elapsed = timer.ElapsedTimeSpan.Milliseconds;

            Log.Info("elapsed:" + elapsed, this);
            timer.Stop();
        }
        public ZigzagWin(string [] argv)
        {
            InitializeComponent();

            mFont = new Font("Arial", 10);

            mApp = new ZigzagApp();
            mApp.Init(argv);
            mHighResTimer = new HighResTimer();

            mFormsTimer          = new System.Windows.Forms.Timer();
            mFormsTimer.Interval = 30; // 100 milliseconds is a tenth of a second
            mFormsTimer.Tick    += new System.EventHandler(this.TimerEventProcessor);

            this.MouseClick  += new MouseEventHandler(On_pnlViewPort_Click);
            this.SizeChanged += new EventHandler(On_pnlViewPort_Size);
            this.Load        += new EventHandler(DashFireWin_Load);
        }
        public SitecoreSearchResultCollection FieldSearch(QueryInfo[] qis, int maxResults)
        {
            HighResTimer timer = new HighResTimer(true);
            var combinedQuery = new CombinedQuery();
            foreach (var qi in qis)
            {
                var q = GetQuery(qi);
                if (q != null)
                    combinedQuery.Add(q, qi.SitecoreSearchQueryOccurance);
            }

            SearchResultCollection results = null;

            if (combinedQuery.Clauses.Count > 0)
                results = GetSearchHits(combinedQuery, maxResults);

            return results != null
                    ? new SitecoreSearchResultCollection(results, timer.Elapsed())
                    : null;
        }
Example #21
0
        private ResizedFrame(Frame orig, Size render)
        {
            OriginalFrame = orig;
            RenderSize    = render;
            CreationTick  = HighResTimer.GetCurrentTickCount();

            // resize original Bitmap
            CreateResizedGDIBitmap(orig.Tilesheet, ref NewBmp, ref ResizedGraphics, ref hDC, ref hBmp);

            // resize Mask of original Bitmap
            if (OriginalFrame.Tilesheet.Mask != null)
            {
                CreateResizedGDIBitmap(orig.Tilesheet.Mask, ref NewBmpMask, ref ResizedGraphicsMask, ref hDCMask, ref hBmpMask);
            }

            // hook into Tilesheet Disposed event
            orig.Tilesheet.Disposed += Tilesheet_Disposed;

            ResizedFrameCache.Add(this.Id, this);
        }
Example #22
0
        private static void Cycle()
        {
            long tick = HighResTimer.GetCurrentTickCount();

            // throttle time hasn't passed; do background tasks
            if ((Configuration.Settings.TargetFPS > 0) && ((double)(tick - _lastTick) < (((double)1 / (double)Configuration.Settings.TargetFPS)) * (double)HighResTimer.TicksPerSecond))
            {
                DoBackgroundTasks(tick);

                // flag that the background tasks have been run this "tick"
                _backgroundRun = true;
            }
            else        // Settings.Throttle time has passed since last tick...
            {
                // make sure background rendering done at least once
                if (!_backgroundRun)
                {
                    DoBackgroundTasks(tick);
                }

                DoForegroundTasks(tick);

                // this "tick" complete, reset flag for next tick
                _backgroundRun = false;
            }

            // increment CPS counter
            _grossCyclesThisMeasure++;
            _grossCycles++;

            // if 0 or negative, sampling is turned off
            if (Configuration.Settings.SamplingTimeForCPS > 0)
            {
                CalculateCPS(tick);
            }
        }
Example #23
0
        public void EndFrame()
        {
            HighResTimer.QueryPerformanceCounter(ref m_frameEnd);
            long elapsed = m_frameEnd - m_frameStart;

            if (elapsed < 1)
            {
                elapsed = 1;        // Ensure we're not negative or DBZ
            }
            // Update our running total.
            m_runningTotal        -= times[m_currentSample];
            times[m_currentSample] = elapsed;
            m_runningTotal        += times[m_currentSample];

            // Store elapsed value for exact FPS calculations;
            m_lastElapsed = elapsed;

            m_currentSample++;
            m_totalFrames++;
            if (m_currentSample >= times.Length)
            {
                m_currentSample = 0;
            }
        }
Example #24
0
 public static void ResetTotalTimeRunning()
 {
     _startTick = HighResTimer.GetCurrentTickCount();
 }
Example #25
0
 private static ulong GetMicroSeconds()
 {
     return(HighResTimer.GetCurrent());
 }
Example #26
0
        /// <summary>
        /// Gets the items from the GetIndexes()
        /// </summary>
        /// <param name="queryString">
        /// The query string.
        /// </param>
        /// <param name="useQueryParser">
        /// if set to <c>true</c> [use query parser].
        /// </param>
        /// <returns>
        /// Returns Query Result
        /// </returns>
        public QueryResult GetItems(string queryString, bool useQueryParser)
        {
            // Result object used to pass result and errormessages back to sender.
            QueryResult result = new QueryResult();

            List <string> indexes = this.GetIndexes();

            string[] resultItemIds = null;
            foreach (string indexName in indexes)
            {
                string       database = "master";
                HighResTimer timer    = new HighResTimer(true);

                // get the specified index
                Sitecore.Search.Index searchIndex = SearchManager.GetIndex(indexName);

                // get the database to perform the search in..
                Database db = Factory.GetDatabase(database);

                SearchHits hits;
                try
                {
                    if (useQueryParser)
                    {
                        using (IndexSearchContext searchContext = searchIndex.CreateSearchContext())
                        {
                            // get a new standard analyser so we can create a query..
                            Analyzer    analyzer    = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
                            QueryParser queryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, queryString, analyzer);
                            Query       qry         = queryParser.Query("_content");
                            hits = searchContext.Search(qry, int.MaxValue);
                        }
                    }
                    else
                    {
                        using (IndexSearchContext searchContext = searchIndex.CreateSearchContext())
                        {
                            // perform the search and get the results back as a Hits list..
                            hits = searchContext.Search(queryString, int.MaxValue);
                        }
                    }

                    result.Success = true;

                    resultItemIds = new string[hits.Length];

                    int i = 0;

                    foreach (Document document in hits.Documents)
                    {
                        string str = document.Get("_docID");
                        resultItemIds[i++] = str;
                    }
                }
                catch (ParseException e)
                {
                    result.ErrorMessage   = e.Message;
                    result.ParseException = e;
                    result.Success        = false;
                }
            }

            result.Result = resultItemIds;
            return(result);
        }
Example #27
0
        public void CreateSearchPath(algorithm_type Algo)
        {
            //set current algorithm
            m_CurrentAlgorithm = Algo;

            //clear any existing path
            m_Path.Clear();
            m_SubTree.Clear();

            if (m_CurrentAlgorithm == algorithm_type.none)
            {
                return;
            }

            //create and start a timer
            HighResTimer tempTimer = new HighResTimer();

            tempTimer.Start();

            BaseGraphSearchAlgo SearchAlgo = null;

            //do the search
            switch (m_CurrentAlgorithm)
            {
            case algorithm_type.search_dfs:

                SearchAlgo = new Graph_SearchDFS(m_Graph, m_iSourceCell, m_iTargetCell);
                break;

            case algorithm_type.search_bfs:

                SearchAlgo = new Graph_SearchBFS(m_Graph, m_iSourceCell, m_iTargetCell);
                break;

            case algorithm_type.search_dijkstra:

                SearchAlgo = new Graph_SearchDijkstra(m_Graph, m_iSourceCell, m_iTargetCell);
                break;

            case algorithm_type.search_astar:

                SearchAlgo = new Graph_SearchAStar(m_Graph, m_iSourceCell, m_iTargetCell, EuclidianDistance);
                break;

            default:
                throw new Exception("<PathFinder::CreateSearchPath>: algorithm_type does not exist");
            }

            tempTimer.Stop();

            //record the time taken
            m_dTimeTaken = tempTimer.RunningTime;

            if (SearchAlgo != null)
            {
                //now grab the path (if one has been found)
                if (SearchAlgo.Found())
                {
                    m_Path = SearchAlgo.GetPathToTarget();
                }

                m_SubTree = SearchAlgo.GetSearchTree();

                m_dCostToTarget = SearchAlgo.GetCostToTarget();
            }
        }
Example #28
0
 public TimerReport(string name)
 {
     _name  = name;
     _timer = new HighResTimer(true);
 }
Example #29
0
 public TimerReport(string name)
 {
     this._name = name;
     this._timer = new HighResTimer(true);
 }
Example #30
0
 public void Restart()
 {
     startTicks = HighResTimer.GetCurrent();
     isRunning  = true;
 }
    /// <summary>
    /// Gets the items from the GetIndexes()
    /// </summary>
    /// <param name="queryString">
    /// The query string.
    /// </param>
    /// <param name="useQueryParser">
    /// if set to <c>true</c> [use query parser].
    /// </param>
    /// <returns>
    /// Returns Query Result
    /// </returns>
    public QueryResult GetItems(string queryString, bool useQueryParser)
    {
      // Result object used to pass result and errormessages back to sender.
      QueryResult result = new QueryResult();

      List<string> indexes = this.GetIndexes();
      string[] resultItemIds = null;
      foreach (string indexName in indexes)
      {
        string database = "master";
        HighResTimer timer = new HighResTimer(true);

        // get the specified index
        Sitecore.Search.Index searchIndex = SearchManager.GetIndex(indexName);

        // get the database to perform the search in..
        Database db = Factory.GetDatabase(database);

        SearchHits hits;
        try
        {
          if (useQueryParser)
          {
            using (IndexSearchContext searchContext = searchIndex.CreateSearchContext())
            {
              // get a new standard analyser so we can create a query..
              Analyzer analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
              QueryParser queryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, queryString, analyzer);
              Query qry = queryParser.Query("_content");
              hits = searchContext.Search(qry, int.MaxValue);
            }
          }
          else
          {
            using (IndexSearchContext searchContext = searchIndex.CreateSearchContext())
            {
              // perform the search and get the results back as a Hits list..
              hits = searchContext.Search(queryString, int.MaxValue);
            }
          }

          result.Success = true;
          
          resultItemIds = new string[hits.Length];

          int i = 0;

          foreach (Document document in hits.Documents)
          {
            string str = document.Get("_docID");
            resultItemIds[i++] = str;
          }
        }
        catch (ParseException e)
        {
          result.ErrorMessage = e.Message;
          result.ParseException = e;
          result.Success = false;
        }
      }

      result.Result = resultItemIds;
      return result;
    }
Example #32
0
 public void Stop()
 {
     isRunning = false;
     stopTicks = HighResTimer.GetCurrent();
 }
Example #33
0
 public void BeginFrame()
 {
     HighResTimer.QueryPerformanceCounter(ref m_frameStart);
 }