Skip to content

Commit

Permalink
"use strict";
Browse files Browse the repository at this point in the history
  • Loading branch information
endes0 committed Mar 7, 2024
1 parent 03d6541 commit ae4bc39
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 111 deletions.
16 changes: 9 additions & 7 deletions src/interface/components/Superescalar/tab/StatsTabComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"use strict";
import * as React from "react";
import { WithTranslation, withTranslation } from "react-i18next";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { AnyAction, Dispatch, bindActionCreators } from "redux";

import ReactECharts from "echarts-for-react";
import { GlobalState } from "../../../reducers";

const mapStateToProps = (state) => {
const mapStateToProps = (state: GlobalState) => {
return {
commited: state.Machine.stats.commited,
discarded: state.Machine.stats.discarded,
Expand All @@ -18,7 +20,7 @@ const mapStateToProps = (state) => {
};
};

const mapDispatchToProps = (dispatch) => {
const mapDispatchToProps = (dispatch: Dispatch<AnyAction>) => {
return {
actions: bindActionCreators({}, dispatch),
};
Expand Down Expand Up @@ -89,7 +91,7 @@ export const StatsTabComponent: React.FC = (

series:
props.statusesCount &&
Array.from(props.statusesCount.keys()).map((statusName) => {
Array.from(props.statusesCount.keys()).map((statusName: string) => {
return {
name: props.t("stats.statuses." + statusName),
type: "bar",
Expand Down Expand Up @@ -165,13 +167,13 @@ export const StatsTabComponent: React.FC = (

series:
props.unitsOcupation &&
Array.from(props.unitsOcupation.keys()).map((unitName) => {
Array.from(props.unitsOcupation.keys()).map((unitName: string) => {
return {
name: props.t("stats.units." + unitName),
type: "line",
data: props.unitsOcupation
.get(unitName)
.map((value) => value * 100),
.map((value: number) => value * 100),
};
}),
}}
Expand Down Expand Up @@ -285,7 +287,7 @@ export const StatsTabComponent: React.FC = (
</thead>
<tbody>
{props.instrCommitPercentage &&
props.instrCommitPercentage.map((d) => (
props.instrCommitPercentage.map((d: { name: string; value: number; }) => (
<tr key={d.name}>
<th scope="row">{d.name}</th>
<td>{props.code[d.name].toString()}</td>
Expand Down
189 changes: 94 additions & 95 deletions src/interface/components/VLIW/tab/StatsTabComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,108 @@
"use strict";
import * as React from "react";
import { withTranslation } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { AnyAction, Dispatch, bindActionCreators } from "redux";

import ReactECharts from "echarts-for-react";

export class StatsTabComponent extends React.Component<any, any> {
constructor(props: any) {
super(props);
}
type StatsTabComponentProps = WithTranslation &
ReturnType<typeof mapStateToProps> &
ReturnType<typeof mapDispatchToProps>;

export const StatsTabComponent: React.FC = (
props: StatsTabComponentProps
): React.ReactNode => {
return (
<div className="container text-center">
<div className="row">
<div className="col">
<ReactECharts
style={{
height: "25rem",
width: "100%",
}}
option={{
title: {
text: props.t("stats.unitsOcupation"),
left: "center",
},

legend: {
top: "bottom",
},

toolbox: {
feature: {
saveAsImage: {},
dataView: {
readOnly: true,
lang: [
props.t("stats.toolbox.dataView"),
props.t("stats.toolbox.close"),
props.t("stats.toolbox.refresh"),
],
},
},
},

tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
},
},

render() {
return (
<div className="container text-center">
<div className="row">
<div className="col">
xAxis: {
type: "category",
},

yAxis: {
type: "value",
max: 100,
axisLabel: {
formatter: "{value}%",
},
},

series:
props.unitsOcupation &&
Array.from(props.unitsOcupation.keys()).map((unitName) => {
return {
name: props.t("stats.units." + unitName),
type: "line",
data: props.unitsOcupation
.get(unitName)
.map((value: number) => value * 100),
};
}),
}}
/>
</div>
</div>
<div className="row">
<div className="col">
{props.cyclesPerReplication.length > 0 && (
<ReactECharts
style={{
height: "25rem",
height: "13rem",
width: "100%",
}}
option={{
title: {
text: this.props.t("stats.unitsOcupation"),
text: props.t("stats.cycles"),
left: "center",
},

legend: {
top: "bottom",
},

toolbox: {
feature: {
saveAsImage: {},
dataView: {
readOnly: true,
lang: [
this.props.t("stats.toolbox.dataView"),
this.props.t("stats.toolbox.close"),
this.props.t("stats.toolbox.refresh"),
props.t("stats.toolbox.dataView"),
props.t("stats.toolbox.close"),
props.t("stats.toolbox.refresh"),
],
},
},
Expand All @@ -57,86 +121,21 @@ export class StatsTabComponent extends React.Component<any, any> {

yAxis: {
type: "value",
max: 100,
axisLabel: {
formatter: "{value}%",
},
},

series:
this.props.unitsOcupation &&
Array.from(this.props.unitsOcupation.keys()).map(
(unitName) => {
return {
name: this.props.t("stats.units." + unitName),
type: "line",
data: this.props.unitsOcupation
.get(unitName)
.map((value) => value * 100),
};
}
),
series: {
name: props.t("stats.cycles"),
type: "line",
data: props.cyclesPerReplication,
},
}}
/>
</div>
</div>
<div className="row">
<div className="col">
{this.props.cyclesPerReplication.length > 0 && (
<ReactECharts
style={{
height: "13rem",
width: "100%",
}}
option={{
title: {
text: this.props.t("stats.cycles"),
left: "center",
},

toolbox: {
feature: {
saveAsImage: {},
dataView: {
readOnly: true,
lang: [
this.props.t("stats.toolbox.dataView"),
this.props.t("stats.toolbox.close"),
this.props.t("stats.toolbox.refresh"),
],
},
},
},

tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
},
},

xAxis: {
type: "category",
},

yAxis: {
type: "value",
},

series: {
name: this.props.t("stats.cycles"),
type: "line",
data: this.props.cyclesPerReplication,
},
}}
/>
)}
</div>
)}
</div>
</div>
);
}
}
</div>
);
};

const mapStateToProps = (state) => {
return {
Expand All @@ -151,7 +150,7 @@ const mapStateToProps = (state) => {
};
};

const mapDispatchToProps = (dispatch) => {
const mapDispatchToProps = (dispatch: Dispatch<AnyAction>) => {
return {
actions: bindActionCreators({}, dispatch),
};
Expand Down
2 changes: 1 addition & 1 deletion src/interface/reducers/color.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { COLOR_CELL } from "../actions";

const initialState = {
export const initialState = {
uuidColors: {},
IidColors: {}
}
Expand Down
12 changes: 6 additions & 6 deletions src/interface/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { combineReducers } from 'redux'
import { MachineReducers } from './machine'
import { UiReducers } from './ui'
import { ColorReducers } from './color'
import { MachineReducers, initialState as machineInitialState } from './machine'
import { UiReducers, initialState as uiInitialState } from './ui'
import { ColorReducers, initialState as colorsInitialState } from './color'

export interface GlobalState {
Machine: typeof MachineReducers,
Ui: typeof UiReducers,
Colors: typeof ColorReducers
Machine: typeof machineInitialState,
Ui: typeof uiInitialState,
Colors: typeof colorsInitialState
}

export default combineReducers({
Expand Down
2 changes: 1 addition & 1 deletion src/interface/reducers/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SET_CYCLES_PER_REPLICATION
} from '../actions/stats-actions';

const initialState = {
export const initialState = {
isLoadModalOpen: false,
isAuthorModalOpen: false,
isOptionsModalOpen: false,
Expand Down
3 changes: 2 additions & 1 deletion src/stats/aggregator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
import { Stats, InstructionStatsEntry } from "./stats";

export interface StatEntry {
Expand Down Expand Up @@ -105,7 +106,7 @@ export class StatsAgregator {
}
}

for (let [key, value] of result) {
for (let [, value] of result) {
for (let prop in value) {
if (value.hasOwnProperty(prop)) {
value[prop] = value[prop] / this._stats.length;
Expand Down
1 change: 1 addition & 0 deletions src/stats/stats.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
export interface InstructionStatsEntry {
instructionId: number;

Expand Down

0 comments on commit ae4bc39

Please sign in to comment.