Skip to content

Commit

Permalink
Merge pull request #237 from dalibo/block_size_as_bytes
Browse files Browse the repository at this point in the history
Block size as bytes
  • Loading branch information
pgiraud authored Jul 10, 2020
2 parents 11808fa + 19e2f32 commit a615a8e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/assets/scss/_plan.scss
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ $connector-line: 2px solid darken($line-color, 10%);
}
}

.tippy-popper .tippy-tooltip {
text-align: left;
}
.tippy-popper .text-muted {
color: inherit !important;
}
Expand Down
10 changes: 5 additions & 5 deletions src/components/Diagram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<script lang="ts">
import * as _ from 'lodash';
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import { duration, durationClass, rows, factor } from '@/filters';
import { blocks, duration, durationClass, rows, factor } from '@/filters';
import { EstimateDirection, CenterMode, BuffersMetric, HighlightMode, NodeProp, Metric } from '../enums';
import Node from '@/inode';
import { IPlan } from '../iplan';
Expand Down Expand Up @@ -278,10 +278,10 @@ export default class Diagram extends Vue {
written = node[NodeProp.EXCLUSIVE_LOCAL_WRITTEN_BLOCKS];
break;
}
text += hit ? '<br>Hit: ' + rows(hit) : '';
text += read ? '<br>Read: ' + rows(read) : '';
text += dirtied ? '<br>Dirtied: ' + rows(dirtied) : '';
text += written ? '<br>Written: ' + rows(written) : '';
text += hit ? '<br>Hit: ' + blocks(hit) : '';
text += read ? '<br>Read: ' + blocks(read) : '';
text += dirtied ? '<br>Dirtied: ' + blocks(dirtied) : '';
text += written ? '<br>Written: ' + blocks(written) : '';
text = text ? text : ' N/A';
switch (this.viewOptions.buffersMetric) {
case BuffersMetric.shared:
Expand Down
24 changes: 12 additions & 12 deletions src/components/PlanNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,24 @@
</tr>
<tr>
<th>Shared</th>
<td class="text-right">{{ formattedProp('EXCLUSIVE_SHARED_HIT_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_SHARED_READ_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_SHARED_DIRTIED_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_SHARED_WRITTEN_BLOCKS') || '-' }}</td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_SHARED_HIT_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_SHARED_READ_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_SHARED_DIRTIED_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_SHARED_WRITTEN_BLOCKS') || '-'"></td>
</tr>
<tr>
<th>Temp</th>
<td class="text-right">{{ formattedProp('EXCLUSIVE_TEMP_HIT_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_TEMP_READ_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_TEMP_DIRTIED_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_TEMP_WRITTEN_BLOCKS') || '-' }}</td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_TEMP_HIT_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_TEMP_READ_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_TEMP_DIRTIED_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_TEMP_WRITTEN_BLOCKS') || '-'"></td>
</tr>
<tr>
<th>Local</th>
<td class="text-right">{{ formattedProp('EXCLUSIVE_LOCAL_HIT_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_LOCAL_READ_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_LOCAL_DIRTIED_BLOCKS') || '-' }}</td>
<td class="text-right">{{ formattedProp('EXCLUSIVE_LOCAL_WRITTEN_BLOCKS') || '-' }}</td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_LOCAL_HIT_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_LOCAL_READ_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_LOCAL_DIRTIED_BLOCKS') || '-'"></td>
<td class="text-right" v-html="formattedProp('EXCLUSIVE_LOCAL_WRITTEN_BLOCKS') || '-'"></td>
</tr>
</table>
<!-- iobuffer tab -->
Expand Down
14 changes: 14 additions & 0 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export enum PropType {
json,
space,
increment,
blocks,
}

export const nodePropTypes: any = {};
Expand Down Expand Up @@ -176,6 +177,19 @@ nodePropTypes[NodeProp.IO_WRITE_TIME] = PropType.duration;
nodePropTypes[NodeProp.EXCLUSIVE_IO_READ_TIME] = PropType.duration;
nodePropTypes[NodeProp.EXCLUSIVE_IO_WRITE_TIME] = PropType.duration;

nodePropTypes[NodeProp.EXCLUSIVE_SHARED_HIT_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_SHARED_READ_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_SHARED_DIRTIED_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_SHARED_WRITTEN_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_TEMP_HIT_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_TEMP_READ_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_TEMP_DIRTIED_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_TEMP_WRITTEN_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_LOCAL_HIT_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_LOCAL_READ_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_LOCAL_DIRTIED_BLOCKS] = PropType.blocks;
nodePropTypes[NodeProp.EXCLUSIVE_LOCAL_WRITTEN_BLOCKS] = PropType.blocks;

export class WorkerProp {
// plan property keys
public static WORKER_NUMBER: string = 'Worker Number';
Expand Down
12 changes: 11 additions & 1 deletion src/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ export function formatBytes(bytes: number, decimals = 2) {
const dm = decimals < 0 ? 0 : decimals;
const units = ['Bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
const compiled = _.template('${value}&nbsp;<span class="text-muted">${unit}</span>');
const compiled = _.template('${value}&nbsp;${unit}');
const value = parseFloat((bytes / Math.pow(k, i)).toFixed(dm)).toLocaleString();
return compiled({value, unit: units[i]});
}

export function blocks(value: number): string {
if (!value) {
return '';
}
return value.toLocaleString() + '&nbsp;<span class="text-muted">|</span>&nbsp;<small>' +
formatBytes(value * 8 * 1024) + '</small>';
}

export function formatNodeProp(key: string, value: any, detail: boolean): string {
if (_.has(nodePropTypes, key)) {
if (nodePropTypes[key] === PropType.duration) {
Expand All @@ -92,6 +100,8 @@ export function formatNodeProp(key: string, value: any, detail: boolean): string
return JSON.stringify(value, null, 2);
} else if (nodePropTypes[key] === PropType.space) {
return space(value);
} else if (nodePropTypes[key] === PropType.blocks) {
return blocks(value);
}
}
return value;
Expand Down

0 comments on commit a615a8e

Please sign in to comment.