BuildingCoder.CmdCollectorPerformance.BenchmarkAllLevels C# (CSharp) Метод

BenchmarkAllLevels() приватный Метод

Benchmark several different approaches to using filtered collectors to retrieve all levels in the model, and measure the time required to create IList and List collections from them.
private BenchmarkAllLevels ( int nLevels ) : void
nLevels int
Результат void
        void BenchmarkAllLevels( int nLevels )
        {
            Type t = typeof( Level );
              int n;

              using( JtTimer pt = new JtTimer(
            "Empty method *" ) )
              {
            EmptyMethod( t );
              }

              using( JtTimer pt = new JtTimer(
            "NotElementType *" ) )
              {
            FilteredElementCollector a
              = GetNonElementTypeElements();
              }

              using( JtTimer pt = new JtTimer(
            "NotElementType as IList *" ) )
              {
            IList<Element> a
              = GetNonElementTypeElements().ToElements();
            n = a.Count;
              }
              Debug.Assert( nLevels <= n,
            "expected to retrieve all non-element-type elements" );

              using( JtTimer pt = new JtTimer(
            "NotElementType as List *" ) )
              {
            List<Element> a = new List<Element>(
              GetNonElementTypeElements() );

            n = a.Count;
              }
              Debug.Assert( nLevels <= n,
            "expected to retrieve all non-element-type elements" );

              using( JtTimer pt = new JtTimer( "Explicit" ) )
              {
            List<Element> a
              = GetElementsOfTypeUsingExplicitCode( t );

            n = a.Count;
              }
              Debug.Assert( nLevels == n,
            "expected to retrieve all levels" );

              using( JtTimer pt = new JtTimer( "Linq" ) )
              {
            IEnumerable<Element> a =
              GetElementsOfTypeUsingLinq( t );

            n = a.Count<Element>();
              }
              Debug.Assert( nLevels == n,
            "expected to retrieve all levels" );

              using( JtTimer pt = new JtTimer(
            "Linq as List" ) )
              {
            List<Element> a = new List<Element>(
              GetElementsOfTypeUsingLinq( t ) );

            n = a.Count;
              }
              Debug.Assert( nLevels == n,
            "expected to retrieve all levels" );

              using( JtTimer pt = new JtTimer( "Collector" ) )
              {
            FilteredElementCollector a
              = GetElementsOfType( t );
              }

              using( JtTimer pt = new JtTimer(
            "Collector as IList" ) )
              {
            IList<Element> a
              = GetElementsOfType( t ).ToElements();

            n = a.Count;
              }
              Debug.Assert( nLevels == n,
            "expected to retrieve all levels" );

              using( JtTimer pt = new JtTimer(
            "Collector as List" ) )
              {
            List<Element> a = new List<Element>(
              GetElementsOfType( t ) );

            n = a.Count;
              }
              Debug.Assert( nLevels == n,
            "expected to retrieve all levels" );
        }