예제 #1
0
파일: Program.cs 프로젝트: Ljubo6/SoftUni-1
    static void Main(string[] args)
    {
        var agency         = new Agency();
        var inputGenerator = new InputGenerator();

        List <Invoice> invoices = inputGenerator.GenerateInvoices(10000);

        foreach (var inv in invoices)
        {
            agency.Create(inv);
        }

        var mostOccur = inputGenerator.MostOccur(invoices, x => x.DueDate);

        DateTime mostOccurDueDate = mostOccur.Key;

        DateTime minDueDate = mostOccurDueDate.AddYears(-1);
        DateTime maxDueDate = mostOccurDueDate.AddYears(1);

        var watch = new Stopwatch();

        watch.Start();
        try
        {
            agency.ThrowInvoiceInPeriod(minDueDate, maxDueDate);
        }
        catch (ArgumentException ignored)
        {
        }
        watch.Stop();

        long elapsedTime = watch.ElapsedMilliseconds;

        System.Console.WriteLine(elapsedTime);
    }
    public void RemoveWithBrand_With_100_000_Entities()
    {
        List <Computer> computers = this.inputGenerator.GenerateComputers(100000);
        Brand           brand     = inputGenerator.MostOccur(computers, x => x.Brand).Key;

        foreach (var comp in computers)
        {
            microsystems.CreateComputer(comp);
        }
        var watch = new Stopwatch();

        watch.Start();

        microsystems.RemoveWithBrand(brand);


        watch.Stop();

        long elapsedTime = watch.ElapsedMilliseconds;

        // throw new ArgumentException("time: " + elapsedTime);

        Assert.IsTrue(elapsedTime <= 65);
    }
    public void GetInRangePrice_With_10_000_Entities()
    {
        List <Computer> computers = this.inputGenerator.GenerateComputers(10000);
        var             color     = inputGenerator.MostOccur(computers, x => x.Color).Key;

        foreach (var comp in computers)
        {
            microsystems.CreateComputer(comp);
        }
        var watch = new Stopwatch();

        watch.Start();

        microsystems.GetInRangePrice(1000, 5000);


        watch.Stop();

        long elapsedTime = watch.ElapsedMilliseconds;

        // throw new ArgumentException("time: " + elapsedTime);

        Assert.IsTrue(elapsedTime <= 30);
    }
    public void GetAllWithScreenSize_With_200_000_Entities()
    {
        List <Computer> computers = this.inputGenerator.GenerateComputers(200000);
        var             size      = inputGenerator.MostOccur(computers, x => x.ScreenSize).Key;

        foreach (var comp in computers)
        {
            microsystems.CreateComputer(comp);
        }
        var watch = new Stopwatch();

        watch.Start();

        microsystems.GetAllWithScreenSize(size);


        watch.Stop();

        long elapsedTime = watch.ElapsedMilliseconds;

        //throw new ArgumentException("time: " + elapsedTime);

        Assert.IsTrue(elapsedTime <= 115);
    }