Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
andrestoll committed Feb 9, 2024
1 parent b7655fa commit 9a69a51
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ Please note that the input function will be executed in your AWS account - perfo

It's pretty simple and you can visually inspect each step in the AWS management console.


![state-machine](imgs/state-machine-screenshot.png?raw=true)


## What results can I expect from Lambda Power Tuning?

The state machine will generate a visualization of average cost and speed for each power configuration.
Expand All @@ -36,17 +34,14 @@ How to interpret the chart above: execution time goes from 35s with 128MB to les

How to interpret the chart above: execution time goes from 2.4s with 128MB to 300ms with 1GB, for the very same average cost.


## How to deploy the state machine
## How to deploy the state machine

There are a few options documented [here](README-DEPLOY.md).


## How to execute the state machine

You can execute the state machine manually or programmatically, see the documentation [here](README-EXECUTE.md).


## State Machine Input and Output

Here's a typical execution input with basic parameters:
Expand Down Expand Up @@ -81,7 +76,6 @@ The state machine output will look like this:

Full output documentation [here](README-INPUT-OUTPUT.md#user-content-state-machine-output).


## Data visualization

You can visually inspect the tuning results to identify the optimal tradeoff between cost and performance.
Expand All @@ -106,12 +100,10 @@ Power Tuner UI repository: [mattymoomoo/aws-power-tuner-ui](https://github.com/m

[Here](README-ADVANCED.md) you can find out more about some advanced features of this project, its internals, and some considerations about security and execution cost.


## CHANGELOG (SAR versioning)

From most recent to oldest, with major releases in bold:

* *4.3.4* (2024-02-07): optionally include all results in output
* *4.3.3* (2023-10-30): parametrized currency for visualization URL (USD|CNY)
* *4.3.2* (2023-08-16): new disablePayloadLogs flag, updated documentation
* *4.3.1* (2023-05-09): update dependencies, add VPC Configuration support, use Billed Duration instead Duration from logs, update state machine with ItemSelector
Expand Down Expand Up @@ -158,7 +150,6 @@ From most recent to oldest, with major releases in bold:
* ***1.0.0*** (2019-05-13): AWS SAM refactor (published on SAR)
* *0.0.1* (2017-03-27): previous project (serverless framework)


## Contributing

Feature requests and pull requests are more than welcome!
Expand Down
13 changes: 11 additions & 2 deletions lambda/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module.exports.handler = async(event, context) => {

const result = findOptimalConfiguration(event);

if (event.includeOutputResults) {
result.stats = event.stats;
if (!!event.includeOutputResults) {
result.stats = removeTotalCostFromStats(event.stats);
}

return result;
Expand Down Expand Up @@ -141,3 +141,12 @@ const findBalanced = (stats, weight) => {
// just return the first one
return stats[0];
};

const removeTotalCostFromStats = (stats) => {
return stats
.map(stat => ({
value: stat.value,
averagePrice: stat.averagePrice,
averageDuration: stat.averageDuration
}));
}
10 changes: 8 additions & 2 deletions test/unit/test-lambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -1661,8 +1661,14 @@ describe('Lambda Functions', async() => {
const result = await invokeForSuccess(handler, event);
expect(result).to.be.an('object');

expect(result).to.have.property('stats', event.stats);
expect(result.stats).to.be(event.stats);
expect(result).to.have.property('stats');
expect(result.stats).to.eql(event.stats.map(stat => ({
value: stat.value,
averagePrice: stat.averagePrice,
averageDuration: stat.averageDuration
})));

expect(result.stats[0]).to.not.have.property('totalCost');

expect(result).to.have.property('power');
expect(result).to.have.property('cost');
Expand Down

0 comments on commit 9a69a51

Please sign in to comment.