Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP Speed
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01534425
Message ID:
01534488
Vues:
106
On my computer:
Jose's code completes in 0.868 seconds and in 0.441 seconds respectively.
C# code (below) completes in 0.29 seconds and 0.016 seconds respectively.
using System;
using System.Text;

namespace SpeedTest
{
    using System.Diagnostics;

    public class Program
    {
        public static void Main()
        {
            SpeedTest();

            Console.Write("\n\nAny key...");
            Console.ReadKey();
        }

        private static void SpeedTest()
        {
            const int MaxIndex = 1000000;

            var stopwatch = new Stopwatch();
            stopwatch.Start();

            for (var index = 0; index < MaxIndex; index++)
            {
                var var1 = Math.Log(index) + 
                    Math.Cos(index) + 
                    Math.Sin(index) + 
                    Math.Log(index) + 
                    Math.Exp(index);
            }

            stopwatch.Stop();
            Console.WriteLine("Test 01: {0}", stopwatch.Elapsed);

            // AM  using string type in .NET for this type of test
            // would be unreasonable. StringBuilder Class is used instead.
            var stringBuilder = new StringBuilder();

            stopwatch.Reset();
            stopwatch.Start();

            for (var index = 0; index < MaxIndex; index++)
            {
                stringBuilder.Append("xx");
            }

            string result = stringBuilder.ToString();

            stopwatch.Stop();
            Console.WriteLine("Test 02: {0}", stopwatch.Elapsed);
        }
    }
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform