-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(events): GPU interface #10162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(events): GPU interface #10162
Changes from all commits
ab80f9d
fd2fcb9
6eb6f0b
81c91a7
7bd9147
cc20ecc
f5922c3
ab57245
310c01a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import ContextBlock from 'app/components/events/contexts/contextBlock'; | ||
import {formatBytes} from 'app/utils'; | ||
|
||
const megaByteInBytes = 1048576; | ||
|
||
class GpuContextType extends React.Component { | ||
static propTypes = { | ||
alias: PropTypes.string.isRequired, | ||
data: PropTypes.object.isRequired, | ||
}; | ||
|
||
formatMemory = memory_size => { | ||
if (!Number.isInteger(memory_size) || memory_size <= 0) { | ||
return null; | ||
} | ||
|
||
// 'usable_memory' is in defined in MB | ||
return formatBytes(memory_size * megaByteInBytes); | ||
}; | ||
|
||
render() { | ||
let { | ||
id, | ||
name, | ||
version, | ||
vendor_name, | ||
vendor_id, | ||
memory_size, | ||
npot_support, | ||
multi_threaded_rendering, | ||
api_type, | ||
...data | ||
} = this.props.data; | ||
|
||
let memory = this.formatMemory(memory_size); | ||
let knownData = [ | ||
['?Name', name], | ||
['?Version', version], | ||
['?Vendor', vendor_name], | ||
['?Memory', memory], | ||
['?NPOT Support', npot_support], | ||
['?Multi-Thread rendering', multi_threaded_rendering], | ||
['?API Type', api_type], | ||
]; | ||
|
||
if (vendor_id > 0) { | ||
knownData.unshift(['?Vendor Id', vendor_id]); | ||
} | ||
|
||
if (id > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition could be combined with the one above it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You just caught a bug there! I should be checking for: |
||
knownData.unshift(['?GPU Id', id]); | ||
} | ||
|
||
return <ContextBlock data={data} knownData={knownData} alias={this.props.alias} />; | ||
} | ||
} | ||
|
||
GpuContextType.getTitle = function(value) { | ||
return 'GPU'; | ||
}; | ||
|
||
export default GpuContextType; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
|
||
import ContextSummary, {OsSummary} from 'app/components/events/contextSummary'; | ||
import ContextSummary, { | ||
OsSummary, | ||
GpuSummary, | ||
} from 'app/components/events/contextSummary'; | ||
|
||
const CONTEXT_USER = { | ||
email: '[email protected]', | ||
|
@@ -172,3 +175,28 @@ describe('OsSummary', function() { | |
}); | ||
}); | ||
}); | ||
|
||
describe('GpuSummary', function() { | ||
describe('render()', function() { | ||
it('should render name and vendor', () => { | ||
const gpu = { | ||
name: 'Mali-T880', | ||
vendor_name: 'ARM', | ||
version: 'OpenGL ES 3.2 v1.r22p0-01rel0.f294e54ceb2cb2d81039204fa4b0402e', | ||
}; | ||
|
||
const wrapper = shallow(<GpuSummary data={gpu} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render unknown when no vendor', () => { | ||
const gpu = { | ||
type: 'gpu', | ||
name: 'Apple A8 GPU', | ||
}; | ||
|
||
const wrapper = shallow(<GpuSummary data={gpu} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.