Changeset 621:6587c09aa20c in make_builder


Ignore:
Timestamp:
27.08.2014 14:46:00 (6 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Added activity log to benchmark make_builder and identify bottlenecks

Location:
src/makebuilder
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/makebuilder/MakeFileBuilder.java

    r616 r621  
    3131import makebuilder.handler.MakeXMLLoader; 
    3232import makebuilder.libdb.LibDB; 
     33import makebuilder.util.ActivityLog; 
    3334import makebuilder.util.Util; 
    3435 
     
    8889    private static MakeFileBuilder instance; 
    8990 
     91    /** Activity log */ 
     92    private final ActivityLog activityLog; 
     93 
    9094    /** 
    9195     * @return Single MakefileBuilder instance 
     
    124128    public MakeFileBuilder(String relBuildDir, String relTempBuildDir) { 
    125129        instance = this; 
     130        activityLog = new ActivityLog("Makebuilder"); 
     131        activityLog.addActivity("Initialization"); 
    126132 
    127133        // init source scanner and paths 
     
    183189 
    184190        // find local dependencies in "external libraries" 
     191        activityLog.addActivity("find local dependencies in external libraries"); 
    185192        LibDB.findLocalDependencies(buildEntities); 
    186193 
    187194        // Check for duplicate targets 
     195        activityLog.addActivity("Check for duplicate targets"); 
    188196        for (BuildEntity be : buildEntities) { 
    189197            for (BuildEntity be2 : buildEntities) { 
     
    196204 
    197205        // Check for files without owner 
     206        activityLog.addActivity("Check for files without owner"); 
    198207        if (opts.get("report-unmanaged-files") != null) { 
    199208            ArrayList<SrcFile> ownerLess = new ArrayList<SrcFile>(); 
     
    213222 
    214223        // process dependencies 
     224        activityLog.addActivity("Processing dependencies"); 
    215225        System.out.println("Processing dependencies..."); 
    216226        for (BuildEntity be : buildEntities) { 
     
    228238 
    229239        // check whether all dependencies are met 
     240        activityLog.addActivity("check whether all dependencies are met"); 
    230241        for (BuildEntity be : buildEntities) { 
    231242            be.checkForCycles(1); 
     
    234245 
    235246        // add available optional libs 
     247        activityLog.addActivity("add available optional libs"); 
    236248        for (BuildEntity be : buildEntities) { 
    237249            be.addOptionalLibs(); 
     
    239251 
    240252        // check for new cycles 
     253        activityLog.addActivity("check for new cycles"); 
    241254        for (BuildEntity be : buildEntities) { 
    242255            be.checkForCycles(2); 
     
    244257 
    245258        // collect external libraries needed for building 
     259        activityLog.addActivity("collect external libraries needed for building"); 
    246260        for (BuildEntity be : buildEntities) { 
    247261            be.mergeExtLibs(); 
     
    249263 
    250264        // add build commands for entity to makefile 
     265        activityLog.addActivity("add build commands for entity to makefile"); 
    251266        for (BuildEntity be : buildEntities) { 
    252267            if (be.missingDep) { 
     
    257272 
    258273        // Write makefile 
     274        activityLog.addActivity("Write makefile"); 
    259275        writeMakefile(); 
    260276 
     
    267283        // completed 
    268284        System.out.println(Util.color("Creating Makefile successful.", Util.Color.GREEN, true)); 
     285 
     286        if (getOptions().printActivityLog) { 
     287            System.out.println("\nActivity Log:\n"); 
     288            activityLog.print(); 
     289        } 
    269290    } 
    270291 
     
    419440        return LibDB.getInstance("native"); 
    420441    } 
     442 
     443    /** 
     444     * @return Activity log 
     445     */ 
     446    public ActivityLog getActivityLog() { 
     447        return activityLog; 
     448    } 
    421449} 
  • src/makebuilder/Options.java

    r597 r621  
    4444    public boolean outputDotFile; 
    4545 
     46    /** Print activity log? */ 
     47    public boolean printActivityLog = false; 
     48 
    4649    /** File name for generated makefile */ 
    4750    public String generatedMakefileName = "Makefile"; 
     
    7376            } else if (s.startsWith("--dotfile")) { 
    7477                outputDotFile = true; 
     78            } else if (s.startsWith("--activitylog")) { 
     79                printActivityLog = true; 
    7580            } else if (s.startsWith("--makefile=")) { 
    7681                generatedMakefileName = s.substring("--makefile=".length()); 
  • src/makebuilder/SourceScanner.java

    r600 r621  
    3535import java.util.TreeMap; 
    3636 
     37import makebuilder.util.ActivityLog; 
    3738import makebuilder.util.ToStringComparator; 
    3839 
     
    102103 
    103104        // find/register all source directories and files 
     105        ActivityLog activityLog = MakeFileBuilder.getInstance().getActivityLog(); 
     106        activityLog.addGroup("Scan source files", "find/register all source directories and files"); 
    104107        LinkedList<SrcDir> dirsToScan = new LinkedList<SrcDir>(); 
    105108        for (String dir : sourceDirs) { 
     
    125128 
    126129        // init include paths of scanned directories 
     130        activityLog.addActivity("init include paths of scanned directories"); 
    127131        for (int i = 0; i < needIncludePaths.size(); i++) { 
    128132            builder.setDefaultIncludePaths(needIncludePaths.get(i), this); 
     
    132136        // load and apply cached information about files 
    133137        if (useCache) { 
     138            activityLog.addActivity("load and apply cached information about files"); 
    134139            SortedMap<String, SrcFile> cachedFileInfo = loadCachedInfo(); 
    135140            if (cachedFileInfo != null) { 
     
    143148 
    144149        // load build files 
     150        activityLog.addActivity("load build files"); 
    145151        for (SrcFile file : tempFiles) { 
    146152            for (BuildFileLoader loader : loaders) { 
     
    151157        // set ownership of files: relate SrcFile instances to BuildEntity instances 
    152158        // heuristic: all files with same base name (no extension) as one of build entity's source files belong to build entity 
     159        activityLog.addActivity("set ownership of files"); 
    153160        for (BuildEntity be : builder.buildEntities) { 
    154161            for (int i = 0, n = be.sources.size(); i < n; i++) { 
     
    165172 
    166173        // scan/process source files 
     174        activityLog.addActivity("scan/process source files"); 
    167175        for (SourceFileHandler handler : handlers) { 
    168176            for (SrcFile file : tempFiles) { 
     
    174182 
    175183        // release resources (cached lines) 
     184        activityLog.addActivity("release resources"); 
    176185        for (SrcFile file : tempFiles) { 
    177186            file.scanCompleted(); 
     
    180189        // save cached info 
    181190        if (useCache) { 
     191            activityLog.addActivity("saving cache"); 
    182192            System.out.print("Saving cache... "); 
    183193            saveCachedInfo(); 
    184194            System.out.println("done"); 
    185195        } 
     196 
     197        activityLog.endGroup(); 
    186198    } 
    187199 
Note: See TracChangeset for help on using the changeset viewer.