-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1573 from memphisdev/RND-382-ui-for-run-benchmark
ui for run benchmark
- Loading branch information
Showing
3 changed files
with
229 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// Copyright 2022-2023 The Memphis.dev Authors | ||
// Licensed under the Memphis Business Source License 1.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// Changed License: [Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0), as published by the Apache Foundation. | ||
// | ||
// https://github.com/memphisdev/memphis/blob/master/LICENSE | ||
// | ||
// Additional Use Grant: You may make use of the Licensed Work (i) only as part of your own product or service, provided it is not a message broker or a message queue product or service; and (ii) provided that you do not use, provide, distribute, or make available the Licensed Work as a Service. | ||
// A "Service" is a commercial offering, product, hosted, or managed service, that allows third parties (other than your own employees and contractors acting on your behalf) to access and/or use the Licensed Work or a substantial set of the features or functionality of the Licensed Work to third parties as a software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar services that compete with Licensor products or services. | ||
|
||
import './style.scss'; | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import Modal from '../modal'; | ||
import { IoRocket } from 'react-icons/io5'; | ||
import Copy from '../copy'; | ||
import CustomTabs from '../Tabs'; | ||
import { githubUrls } from '../../const/globalConst'; | ||
import { SiLinux, SiApple, SiWindows11 } from 'react-icons/si'; | ||
import { LOCAL_STORAGE_BROKER_HOST, LOCAL_STORAGE_ENV, LOCAL_STORAGE_ACCOUNT_ID } from '../../const/localStorageConsts'; | ||
|
||
let write = | ||
'mem bench producer --message-size 128 --count 1000 --concurrency 1 --host <host> --account-id <account-id(not needed for open-source)> --user <client type user> --password <password>'; | ||
let read = | ||
'mem bench consumer --message-size 128 --count 1000 --concurrency 1 --batch-size 50 --host <host> --account-id <account-id(not needed for open-source)> --user <client type user> --password <password>'; | ||
|
||
const RunBenchmarkModal = ({ open, clickOutside }) => { | ||
const [tabValue, setTabValue] = useState('Windows'); | ||
const [writeLink, setWriteLink] = useState(null); | ||
const [readLink, setReadLink] = useState(null); | ||
|
||
useEffect(() => { | ||
let host = | ||
localStorage.getItem(LOCAL_STORAGE_ENV) === 'docker' | ||
? 'localhost' | ||
: localStorage.getItem(LOCAL_STORAGE_BROKER_HOST) | ||
? localStorage.getItem(LOCAL_STORAGE_BROKER_HOST) | ||
: 'memphis.memphis.svc.cluster.local'; | ||
write = write.replace('<host>', host); | ||
write = write.replace('<account-id(not needed for open-source)>', parseInt(localStorage.getItem(LOCAL_STORAGE_ACCOUNT_ID))); | ||
read = write.replace('<host>', host); | ||
read = write.replace('<account-id(not needed for open-source)>', parseInt(localStorage.getItem(LOCAL_STORAGE_ACCOUNT_ID))); | ||
setWriteLink(write); | ||
setReadLink(read); | ||
}, []); | ||
|
||
return ( | ||
<Modal | ||
header={ | ||
<div className="modal-header connector-modal-header"> | ||
<div className="header-img-container"> | ||
<IoRocket className="headerImage" alt="stationImg" style={{ color: '#6557FF' }} /> | ||
</div> | ||
<div className="connector-modal-title"> | ||
<div className="modal-title">Run a benchmark</div> | ||
</div> | ||
</div> | ||
} | ||
className={'modal-wrapper'} | ||
width="550px" | ||
clickOutside={clickOutside} | ||
open={open} | ||
displayButtons={true} | ||
rBtnText={'Close'} | ||
rBtnClick={clickOutside} | ||
> | ||
<div className="benchmark-wrapper"> | ||
<CustomTabs | ||
tabs={['Windows', 'Mac', 'Linux RPM', 'Linux APK']} | ||
icons={[<SiWindows11 />, <SiApple />, <SiLinux />, <SiLinux />]} | ||
size={'small'} | ||
tabValue={tabValue} | ||
onChange={(tabValue) => setTabValue(tabValue)} | ||
/> | ||
|
||
<> | ||
<p className="action"> | ||
<label>Step 1:</label> Install Memphis CLI | ||
</p> | ||
<div className="url-wrapper"> | ||
<p className="url-text"> {githubUrls['cli'][tabValue]}</p> | ||
<div className="icon"> | ||
<Copy width="18" data={githubUrls['cli'][tabValue]} /> | ||
</div> | ||
</div> | ||
<p className="action"> | ||
<label>Step 2:</label> For inspecting write latency, run the following | ||
</p> | ||
<div className="url-wrapper"> | ||
<p className="url-text">{writeLink}</p> | ||
<div className="icon"> | ||
<Copy width="18" data={writeLink || write} /> | ||
</div> | ||
</div> | ||
<p className="action"> | ||
<label>Step 3:</label> For inspecting read latency, run the following | ||
</p> | ||
<div className="url-wrapper"> | ||
<p className="url-text">{readLink || read}</p> | ||
<div className="icon"> | ||
<Copy width="18" data={readLink || read} /> | ||
</div> | ||
</div> | ||
</> | ||
|
||
<span> | ||
<p className="subtitle">Considerations to keep in mind:</p> | ||
<p className="subtitle">1. The latency and throughput largely depend on the internet connection.</p> | ||
<p className="subtitle"> | ||
2.These figures are preliminary and subject to improvement if necessary. Consult with an engineer for further optimization. | ||
</p> | ||
</span> | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default RunBenchmarkModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.benchmark-wrapper { | ||
width: 100%; | ||
height: 100%; | ||
.title { | ||
color: #101828; | ||
font-family: 'InterSemiBold'; | ||
font-size: 18px; | ||
line-height: 28px; | ||
margin-bottom: 5px; | ||
} | ||
.subtitle { | ||
color: #475467; | ||
font-family: 'Inter'; | ||
font-size: 14px; | ||
line-height: 25px; | ||
margin-bottom: 5px; | ||
p { | ||
margin: 0px; | ||
} | ||
} | ||
.secondary-text { | ||
color: #bcbcbc; | ||
font-family: 'Inter'; | ||
font-size: 12px; | ||
line-height: 20px; | ||
} | ||
.url-wrapper { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding-left: 13px; | ||
height: 40px; | ||
border-radius: 4px; | ||
border: 1px solid #e7e7e7; | ||
margin-bottom: 15px; | ||
.url-text { | ||
margin: 0px; | ||
color: #737373; | ||
font-family: 'InterMedium'; | ||
font-size: 14px; | ||
line-height: 20px; | ||
overflow-x: auto; | ||
white-space: nowrap; | ||
max-width: 430px; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.icon { | ||
height: 33px; | ||
width: 37px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background: #fbfbfb; | ||
border-left: 1px solid #e7e7e7; | ||
border-top-right-radius: inherit; | ||
border-bottom-right-radius: inherit; | ||
cursor: pointer; | ||
} | ||
} | ||
.action { | ||
font-size: 14px; | ||
font-family: 'InterMedium'; | ||
margin: 5px 0px; | ||
label { | ||
color: var(--purple); | ||
font-weight: 600; | ||
margin-right: 5px; | ||
} | ||
} | ||
|
||
.ant-tabs-tab .tabs-name { | ||
font-size: 12px; | ||
} | ||
.ant-tabs-tab + .ant-tabs-tab { | ||
margin: 0 0 0 15px; | ||
} | ||
.ant-tabs-tab { | ||
font-size: 12px; | ||
padding: 8px 0px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters