Package cc.redberry.performance

Source Code of cc.redberry.performance.ProductBijectionPerformanceHugeTest

/*
* Copyright (C) 2012 stas
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package cc.redberry.performance;

import cc.redberry.core.context.CC;
import cc.redberry.core.tensor.Product;
import cc.redberry.core.tensor.random.TRandom;
import cc.redberry.transformation.substitutions.n.ProductsBijectionsPort;
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;

/**
*
* @author stas
*/
public class ProductBijectionPerformanceHugeTest {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        CC.getNameManager().reset(-3912578993076521674L);
        TRandom rp = new TRandom(
                4,
                10,
                new int[]{4, 0, 0, 0},
                new int[]{10, 0, 0, 0},
                false);
        rp.reset(-3806751651286565680L);
        System.out.println("Random Seed = " + rp.getSeed());
        System.out.println("NM Seed = " + CC.getNameManager().getSeed());

//        Product t = rp.nextPermutation();
//        ContractionsGraphDrawer.drawToPngFile(t, "/home/stas/Projects/Durty/", "Huge1");


        DescriptiveStatistics timeStats = new DescriptiveStatistics();
        DescriptiveStatistics trysStats = new DescriptiveStatistics();
        int count = -1;
        while (++count < 10) {
            CC.resetTensorNames();
            Product from = rp.nextProduct(15);
            Product target = from.clone();

//            if (from.getContent().getFullContractionStructure().componentCount != 1) {
//                System.out.println(from.getContent().getFullContractionStructure().componentCount);
//                continue;
//            }

            System.out.println(from.size());

            long start = System.nanoTime();
            ProductsBijectionsPort port = new ProductsBijectionsPort(from.getContent(), target.getContent());

            int[] bijection;
            boolean good = false;
            int trys = 0;
            OUTER:
            while ((bijection = port.take()) != null && trys++ < 5000);
            if (trys != 0)
                good = true;
            double millis = 1E-6 * (System.nanoTime() - start);
            timeStats.addValue(millis);
            trysStats.addValue(trys);

            if (!good)
                throw new RuntimeException();
        }
        System.out.println(timeStats);
        System.out.println(trysStats);
    }
}
TOP

Related Classes of cc.redberry.performance.ProductBijectionPerformanceHugeTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.