Skip to content

Commit

Permalink
Base fix for #188 - FlameGraph now (sort of) properly rendered
Browse files Browse the repository at this point in the history
- FlameView now uses the LeanProfile tree aggregation by method id
- Also a *lot* faster now since the number of boxes to be rendered is
one or more orders of magnitude smaller

Still need to work a bit on making it actually look nice though.
  • Loading branch information
rx committed Feb 15, 2017
1 parent 0904834 commit 13de748
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 185 deletions.
Expand Up @@ -25,6 +25,7 @@ public class MethodInfo
/**
* Constructor which extracts the metadata from a {@link Method} and caches the FQMN.
* <p>
*
* @param method the {@link Method} whose metadata will be stored
*/
public MethodInfo(Method method)
Expand All @@ -45,6 +46,7 @@ public MethodInfo(Method method)
/**
* Returns the method id.
* <p>
*
* @return the method id
*/
public long getMethodId()
Expand All @@ -55,6 +57,7 @@ public long getMethodId()
/**
* Returns the file name.
* <p>
*
* @return the file name
*/
public String getFileName()
Expand All @@ -65,6 +68,7 @@ public String getFileName()
/**
* Returns the class name.
* <p>
*
* @return the class name
*/
public String getClassName()
Expand All @@ -75,6 +79,7 @@ public String getClassName()
/**
* Returns the method name.
* <p>
*
* @return the method name
*/
public String getMethodName()
Expand All @@ -85,13 +90,32 @@ public String getMethodName()
/**
* Returns the Fully Qualified Method Name (FQMN), which is equal to the class name + "." + method name.
* <p>
*
* @return the Fully Qualified Method Name
*/
public String getFqmn()
{
return cachedFqmn;
}

/**
* Returns the "simple" class name + "." + method name.
*
* @return the "simple" class name + "." + method name
*/
public String getCompactName()
{

StringBuilder result = new StringBuilder();

int offset = className.lastIndexOf(".");
result.append(offset < 0 ? className : className.substring(offset + 1));

result.append(".").append(methodName);

return result.toString();
}

// Object Implementation

@Override
Expand Down
Expand Up @@ -18,16 +18,17 @@
**/
package com.insightfullogic.honest_profiler.ports.javafx.controller;

import static com.insightfullogic.honest_profiler.core.aggregation.result.ItemType.FLAMEGRAPH;
import static com.insightfullogic.honest_profiler.core.aggregation.result.ItemType.ENTRY;

import com.insightfullogic.honest_profiler.core.profiles.FlameGraph;
import com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node;
import com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree;
import com.insightfullogic.honest_profiler.ports.javafx.model.ProfileContext;
import com.insightfullogic.honest_profiler.ports.javafx.view.FlameGraphCanvas;

import javafx.fxml.FXML;
import javafx.scene.layout.VBox;

public class FlameViewController extends AbstractProfileViewController<FlameGraph, FlameGraph>
public class FlameViewController extends AbstractProfileViewController<Tree, Node>
{
@FXML
private VBox rootContainer;
Expand All @@ -38,7 +39,7 @@ public class FlameViewController extends AbstractProfileViewController<FlameGrap
@FXML
protected void initialize()
{
super.initialize(FLAMEGRAPH);
super.initialize(ENTRY);

rootContainer.getChildren().add(flameView);
}
Expand Down Expand Up @@ -91,7 +92,10 @@ protected void initializeHandlers()
@Override
protected void refresh()
{
flameView = new FlameGraphCanvas();
flameView.accept(getTarget());
rootContainer.getChildren().clear();
rootContainer.getChildren().add(flameView);
}

@Override
Expand Down
Expand Up @@ -175,7 +175,7 @@ public void setProfileContext(ProfileContext prCtx)

// Configure FlameController and bind it to the flameGraph in the ProfileContext
flameController.setProfileContext(prCtx);
flameController.bind(prCtx.flameGraphProperty(), FLAME_EXTRACTOR);
flameController.bind(prCtx.profileProperty(), FLAME_EXTRACTOR);

// Bind the profile sample count display
prCtx.profileProperty().addListener(
Expand Down
@@ -1,5 +1,9 @@
package com.insightfullogic.honest_profiler.ports.javafx.util;

import static com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping.combine;
import static com.insightfullogic.honest_profiler.core.aggregation.grouping.FrameGrouping.BY_METHOD_ID;
import static com.insightfullogic.honest_profiler.core.aggregation.grouping.ThreadGrouping.ALL_TOGETHER;

import java.util.function.Function;

import com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile;
Expand Down Expand Up @@ -36,7 +40,8 @@ public class BindUtil
/**
* Extraction {@link Function} for binding a target to a {@link FlameGraph}.
*/
public static final Function<Object, FlameGraph> FLAME_EXTRACTOR = o -> (FlameGraph)o;
public static final Function<Object, Tree> FLAME_EXTRACTOR = o -> ((AggregationProfile)o)
.getTree(combine(ALL_TOGETHER, BY_METHOD_ID));

/**
* Extraction {@link Function} for binding a target to the {@link Tree} result of aggregating the source
Expand Down Expand Up @@ -88,6 +93,7 @@ public class BindUtil
* {@link AggregationProfile} with the {@link FlatProfileAggregator} using the {@link CombinedGrouping} currently
* selected in the specified {@link AbstractViewController}.
* <p>
*
* @param view the {@link AbstractViewController} which provides the {@link CombinedGrouping} for the aggregation
* @return the extraction {@link Function}
*/
Expand All @@ -101,6 +107,7 @@ public static final Function<Object, Flat> flatExtractor(AbstractViewController<
* {@link AggregationProfile} with the {@link TreeProfileAggregator} using the {@link CombinedGrouping} currently
* selected in the specified {@link AbstractViewController}.
* <p>
*
* @param view the {@link AbstractViewController} which provides the {@link CombinedGrouping} for the aggregation
* @return the extraction {@link Function}
*/
Expand Down

0 comments on commit 13de748

Please sign in to comment.