Skip to content

Commit

Permalink
[CLI] UI_RULER_MINIMUM & UI_RULER_MAXIMUM building constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
cyring committed Jun 9, 2024
1 parent 332dbda commit 9b644fd
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 12 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ ifneq ($(UI_TRANSPARENCY),)
LAYOUT += -D UI_TRANSPARENCY=$(UI_TRANSPARENCY)
endif

ifneq ($(UI_RULER_MINIMUM),)
LAYOUT += -D UI_RULER_MINIMUM=$(UI_RULER_MINIMUM)
endif

ifneq ($(UI_RULER_MAXIMUM),)
LAYOUT += -D UI_RULER_MAXIMUM=$(UI_RULER_MAXIMUM)
endif

.PHONY: all
all: prepare corefreqd corefreq-cli | prepare
@if [ -e $(BUILD)/Makefile ]; then \
Expand Down Expand Up @@ -332,6 +340,8 @@ help:
"| when <F> is 1: don't build and display this area part |\n"\
"| UI_TRANSPARENCY=<F> |\n"\
"| when <F> is 1: build with background transparency |\n"\
"| UI_RULER_MINIMUM=<N>, UI_RULER_MAXIMUM=<N> |\n"\
"| set ruler left or right bound to <N> frequency ratio |\n"\
"| |\n"\
"| Example: |\n"\
"| make CC=gcc OPTIM_LVL=3 FEAT_DBG=1 ARCH_PMC=PCU |\n"\
Expand Down
35 changes: 29 additions & 6 deletions aarch64/corefreq-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,33 @@ void AggregateRatio(void)
}
InsertionSortRuler(Ruler.Uniq, Ruler.Count, BOOST(MIN));

#ifndef UI_RULER_MINIMUM
Ruler.Minimum = (double) lowest;
#elif (UI_RULER_MINIMUM > 0) && (UI_RULER_MINIMUM <= MAX_WIDTH)
Ruler.Minimum = (double) UI_RULER_MINIMUM;
#else
Ruler.Minimum = 1.0;
#endif
#ifndef UI_RULER_MAXIMUM
Ruler.Maximum = (double) highest;
Ruler.Median = (double) RO(Shm)->Cpu[
Ruler.Top[BOOST(ACT)]
].Boost[BOOST(ACT)];
#elif (UI_RULER_MAXIMUM > 0) && (UI_RULER_MAXIMUM <= MAX_WIDTH)
Ruler.Maximum = (double) UI_RULER_MAXIMUM;
#else
Ruler.Maximum = (double) MIN_WIDTH;
#endif
#if !defined(UI_RULER_MINIMUM) && !defined(UI_RULER_MAXIMUM)
{
const double median = (double) RO(Shm)->Cpu[
Ruler.Top[BOOST(ACT)]
].Boost[BOOST(ACT)];

if ((median > Ruler.Minimum) && (median < Ruler.Maximum)) {
Ruler.Median = median;
}
}
#else
Ruler.Median = 0.0;
#endif
if (Ruler.Median == 0.0) {
Ruler.Median = (Ruler.Minimum + Ruler.Maximum) / 2.0;
}
Expand Down Expand Up @@ -13143,8 +13164,10 @@ void Layout_Ruler_Load(Layer *layer, CUINT row)

/* Alternate the color of the frequency ratios */
while (idx--)
{
double fPos = (Ruler.Uniq[idx] * Draw.Area.LoadWidth) / Ruler.Maximum;
if (Ruler.Uniq[idx] <= Ruler.Maximum)
{
const double fPos = (Ruler.Uniq[idx] * Draw.Area.LoadWidth)
/ Ruler.Maximum;
CUINT hPos = (CUINT) fPos;

ASCII tabStop[10+1] = "00";
Expand All @@ -13161,7 +13184,7 @@ void Layout_Ruler_Load(Layer *layer, CUINT row)
bright = !bright;
}
lPos = hPos >= margin ? hPos - margin : margin;
}
}
LayerCopyAt(layer, hLoad1.origin.col, hLoad1.origin.row, hLoad1.length,
hLoad1.attr[Draw.Load], hLoad1.code[Draw.Load]);
}
Expand Down
35 changes: 29 additions & 6 deletions x86_64/corefreq-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,33 @@ void AggregateRatio(void)
}
InsertionSortRuler(Ruler.Uniq, Ruler.Count, BOOST(MIN));

#ifndef UI_RULER_MINIMUM
Ruler.Minimum = (double) lowest;
#elif (UI_RULER_MINIMUM > 0) && (UI_RULER_MINIMUM <= MAX_WIDTH)
Ruler.Minimum = (double) UI_RULER_MINIMUM;
#else
Ruler.Minimum = 1.0;
#endif
#ifndef UI_RULER_MAXIMUM
Ruler.Maximum = (double) highest;
Ruler.Median = (double) RO(Shm)->Cpu[
Ruler.Top[BOOST(ACT)]
].Boost[BOOST(ACT)];
#elif (UI_RULER_MAXIMUM > 0) && (UI_RULER_MAXIMUM <= MAX_WIDTH)
Ruler.Maximum = (double) UI_RULER_MAXIMUM;
#else
Ruler.Maximum = (double) MIN_WIDTH;
#endif
#if !defined(UI_RULER_MINIMUM) && !defined(UI_RULER_MAXIMUM)
{
const double median = (double) RO(Shm)->Cpu[
Ruler.Top[BOOST(ACT)]
].Boost[BOOST(ACT)];

if ((median > Ruler.Minimum) && (median < Ruler.Maximum)) {
Ruler.Median = median;
}
}
#else
Ruler.Median = 0.0;
#endif
if (Ruler.Median == 0.0) {
Ruler.Median = (Ruler.Minimum + Ruler.Maximum) / 2.0;
}
Expand Down Expand Up @@ -17738,8 +17759,10 @@ void Layout_Ruler_Load(Layer *layer, CUINT row)

/* Alternate the color of the frequency ratios */
while (idx--)
{
double fPos = (Ruler.Uniq[idx] * Draw.Area.LoadWidth) / Ruler.Maximum;
if (Ruler.Uniq[idx] <= Ruler.Maximum)
{
const double fPos = (Ruler.Uniq[idx] * Draw.Area.LoadWidth)
/ Ruler.Maximum;
CUINT hPos = (CUINT) fPos;

ASCII tabStop[10+1] = "00";
Expand All @@ -17756,7 +17779,7 @@ void Layout_Ruler_Load(Layer *layer, CUINT row)
bright = !bright;
}
lPos = hPos >= margin ? hPos - margin : margin;
}
}
LayerCopyAt(layer, hLoad1.origin.col, hLoad1.origin.row, hLoad1.length,
hLoad1.attr[Draw.Load], hLoad1.code[Draw.Load]);
}
Expand Down

0 comments on commit 9b644fd

Please sign in to comment.