diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/.DS_Store differ
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..f0257c5
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..d84eb44
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ example
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..e9441bb
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs
new file mode 100644
index 0000000..d4313d4
--- /dev/null
+++ b/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..1b6e1ef
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..5b627cf
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,4 @@
+## Code of Conduct
+This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
+For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
+opensource-codeofconduct@amazon.com with any additional questions or comments.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..914e074
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,61 @@
+# Contributing Guidelines
+
+Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
+documentation, we greatly value feedback and contributions from our community.
+
+Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
+information to effectively respond to your bug report or contribution.
+
+
+## Reporting Bugs/Feature Requests
+
+We welcome you to use the GitHub issue tracker to report bugs or suggest features.
+
+When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
+reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
+
+* A reproducible test case or series of steps
+* The version of our code being used
+* Any modifications you've made relevant to the bug
+* Anything unusual about your environment or deployment
+
+
+## Contributing via Pull Requests
+Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
+
+1. You are working against the latest source on the *master* branch.
+2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
+3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
+
+To send us a pull request, please:
+
+1. Fork the repository.
+2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
+3. Ensure local tests pass.
+4. Commit to your fork using clear commit messages.
+5. Send us a pull request, answering any default questions in the pull request interface.
+6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
+
+GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
+[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
+
+
+## Finding contributions to work on
+Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
+
+
+## Code of Conduct
+This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
+For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
+opensource-codeofconduct@amazon.com with any additional questions or comments.
+
+
+## Security issue notifications
+If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
+
+
+## Licensing
+
+See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
+
+We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..fcc7fa6
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,15 @@
+Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..ca48cd5
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,112 @@
+
+
+
+ 4.0.0
+
+ com.amazon.SampleApplication
+ example
+ 1.0-SNAPSHOT
+
+ example
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+
+ codeguru-profiler
+ codeguru-profiler
+ https://d1osg35nybn3tt.cloudfront.net
+
+
+
+
+
+
+ software.amazon.awssdk
+ bom
+ 2.9.17
+ pom
+ import
+
+
+
+
+
+
+
+ com.amazonaws
+ codeguru-profiler-java-agent
+ 0.1.0
+
+
+
+ com.amazonaws
+ aws-java-sdk-s3
+ 1.11.543
+
+
+
+ software.amazon.awssdk
+ auth
+ 2.9.17
+
+
+
+ com.google.guava
+ guava
+ 28.1-jre
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
diff --git a/src/main/java/com/company/sample/application/App.java b/src/main/java/com/company/sample/application/App.java
new file mode 100644
index 0000000..e59fb6e
--- /dev/null
+++ b/src/main/java/com/company/sample/application/App.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
+import software.amazon.codeguruprofilerjavaagent.Profiler;
+
+public class App {
+
+ public static void main(String[] args) {
+ // start the profiler
+ Profiler.builder().profilingGroupName("CodeGuru-Profiler-Sample")
+ .awsCredentialsProvider(DefaultCredentialsProvider.create())
+ .build()
+ .start();
+
+ App app = new App();
+
+ while(true){
+ app.load();
+ app.load1();
+ app.load2();
+ }
+ }
+
+ private void load() {
+ for (int i =0; i< 1 << 20; ++i){
+ computeShort();
+ }
+ }
+
+ private void load1(){
+ for (int i =0; i< 1 << 20; ++i){
+ computeMedium();
+ }
+ }
+
+ private void load2(){
+ for (int i =0; i< 1 << 20; ++i){
+ computeLong();
+ }
+ }
+
+ private void computeShort(){
+ long x = 0;
+ for (int i =0; i< 1 << 15; ++i){
+ x += i;
+ }
+ }
+
+ private void computeMedium(){
+ long x = 0;
+ for (int i =0; i< 1 << 17; ++i){
+ x += i;
+ }
+ }
+
+ private void computeLong(){
+ long x = 0;
+ for (int i =0; i< 1 << 18; ++i){
+ x += i;
+ }
+ }
+}
+
diff --git a/src/main/java/com/company/sample/application/CreateIllegalOrderThread.java b/src/main/java/com/company/sample/application/CreateIllegalOrderThread.java
new file mode 100644
index 0000000..fe5099d
--- /dev/null
+++ b/src/main/java/com/company/sample/application/CreateIllegalOrderThread.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+public class CreateIllegalOrderThread extends CreateOrderThread{
+
+ private volatile boolean exit = false;
+
+ public void run() {
+ while (!exit) {
+ //some illegal product names
+ createOrder("MANGO");
+ createOrder("STRAWBERRY");
+ createOrder("BANANA");
+ createOrder("GRAPE");
+ createOrder("CHERRY");
+ }
+
+ }
+}
+
diff --git a/src/main/java/com/company/sample/application/CreateOrderThread.java b/src/main/java/com/company/sample/application/CreateOrderThread.java
new file mode 100644
index 0000000..655a981
--- /dev/null
+++ b/src/main/java/com/company/sample/application/CreateOrderThread.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+import com.google.common.base.Optional;
+import java.util.Date;
+import java.util.Random;
+
+public class CreateOrderThread extends Thread{
+
+ static int id = 0;
+
+ private volatile boolean exit = false;
+
+ private static Random random = new Random();
+
+ public void run() {
+ while (!exit) {
+ createOrder("APPLE");
+ createOrder("ORANGE");
+ createOrder("PINEAPPLE");
+ }
+
+ }
+
+ /**
+ * Create random orders
+ * @param productName
+ */
+ public void createOrder(String productName){
+ try {
+ Date orderDate = Util.getRandomDate();
+ Optional optional = ProductName.getProductName(productName);
+
+ if (!optional.isPresent()) {
+ return;
+ }
+
+ ProductName enumProductName = optional.get();
+
+ Order order = new Order(enumProductName, orderDate, random.nextDouble() * 10000, id);
+
+ if (SalesSystem.orders.size() > 10000) {
+ SalesSystem.orders.clear();
+ id = 0;
+ }
+
+ SalesSystem.orders.put(orderDate, order);
+ id++;
+ } catch (IllegalArgumentException e){
+ //e.printStackTrace();
+ //not showing exception stack trace here because it will wash away Profiler's running log
+ }
+ }
+
+}
+
diff --git a/src/main/java/com/company/sample/application/ListOrderThread.java b/src/main/java/com/company/sample/application/ListOrderThread.java
new file mode 100644
index 0000000..ac4dd91
--- /dev/null
+++ b/src/main/java/com/company/sample/application/ListOrderThread.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.text.DateFormat;
+import java.text.DateFormatSymbols;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class ListOrderThread extends Thread {
+ private volatile boolean exit = false;
+
+ /**
+ * Resolution: uncomment the following line to see how this improves the profile.
+ */
+// private static DateFormatSymbols dateFormatSymbols = DateFormatSymbols.getInstance();
+// private static DateFormat myFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", dateFormatSymbols);
+// private static DateFormat todayFormat = new SimpleDateFormat("dd MMM yyyy", dateFormatSymbols);
+ /**
+ * Here DateFormatSymbols are not provided to the SimpleDateFormat
+ * constructor and it will look up on every call, comment the below two lines
+ */
+ private static DateFormat myFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
+ private static DateFormat todayFormat = new SimpleDateFormat("dd MMM yyyy");
+
+ private static String today = null;
+
+ @Override
+ public void run() {
+ while (!exit) {
+ listOrders();
+
+ }
+ }
+
+ /**
+ * List the same day orders
+ */
+ private void listOrders(){
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ String productNames = "";
+
+ synchronized (SalesSystem.orders) {
+ for(Date orderDate: SalesSystem.orders.keySet()){
+ try {
+ objectMapper.setDateFormat(myFormat);
+ Date todayDate = todayFormat.parse(this.today);
+ if(Util.isSameDay(orderDate, todayDate)) {
+ String orderAsString = objectMapper.writeValueAsString(SalesSystem.orders.get(orderDate));
+ System.out.println(orderAsString);
+
+ productNames += "," + SalesSystem.orders.get(orderDate).getProductName();
+ }
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ productNames = productNames.substring(2);
+ System.out.println("Product Names : " + productNames);
+
+ }
+ }
+
+ public void setDate(String today){
+ this.today = today;
+ }
+}
+
diff --git a/src/main/java/com/company/sample/application/Order.java b/src/main/java/com/company/sample/application/Order.java
new file mode 100644
index 0000000..507b3a0
--- /dev/null
+++ b/src/main/java/com/company/sample/application/Order.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+import java.util.Date;
+
+public class Order {
+ private ProductName productName;
+ private Date salesDate;
+ private double amount;
+ private int orderId;
+
+ public Order(ProductName productName, Date salesDate, double amount, int orderId) {
+ this.productName = productName;
+ this.salesDate = salesDate;
+ this.amount = amount;
+ this.orderId = orderId;
+ }
+
+ public ProductName getProductName() {
+ return productName;
+ }
+
+ public void setProductName(ProductName productName) {
+ this.productName = productName;
+ }
+
+ public Date getSalesDate() {
+ return salesDate;
+ }
+
+ public void setSalesDate(Date salesDate) {
+ this.salesDate = salesDate;
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(double amount) {
+ this.amount = amount;
+ }
+
+ public int getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(int orderId) {
+ this.orderId = orderId;
+ }
+}
+
diff --git a/src/main/java/com/company/sample/application/ProductName.java b/src/main/java/com/company/sample/application/ProductName.java
new file mode 100644
index 0000000..9eb2695
--- /dev/null
+++ b/src/main/java/com/company/sample/application/ProductName.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+import com.google.common.base.Enums;
+
+import com.google.common.base.Optional;
+
+public enum ProductName{
+
+ APPLE, ORANGE, PINEAPPLE;
+
+ /**
+ * Pick a random value of the ProductName enum.
+ * @return a random ProductName.
+ */
+ public static Optional getProductName(String name) {
+ /**
+ * Here is attempting to parse a value in the enum, if the value is not found in the enum,
+ * it results in an exception being thrown, comment the below two lines to fix it and uncomment line 43
+ */
+ ProductName productName = ProductName.valueOf(name);
+ return Optional.of(productName);
+
+ /**
+ * Resolution: uncomment the following line to see how this improves the profile.
+ */
+// return Enums.getIfPresent(ProductName.class, name);
+ }
+}
+
diff --git a/src/main/java/com/company/sample/application/SalesSystem.java b/src/main/java/com/company/sample/application/SalesSystem.java
new file mode 100644
index 0000000..1204321
--- /dev/null
+++ b/src/main/java/com/company/sample/application/SalesSystem.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.codeguruprofilerjavaagent.Profiler;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.ZoneId;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class SalesSystem {
+
+ public static ConcurrentHashMap orders = new ConcurrentHashMap();
+
+ public static void main(String[] args) {
+ //Start the profiler
+ Profiler systemProfiler =
+ Profiler.builder().profilingGroupName("CodeGuru-Profiler-Sample")
+ .awsCredentialsProvider(ProfileCredentialsProvider.create("megazone"))
+ .build();
+
+ systemProfiler.start();
+
+ //Start create order thread
+ CreateOrderThread createOrderThread = new CreateOrderThread();
+ createOrderThread.start();
+
+ //Start create Illegal order thread
+ CreateIllegalOrderThread createIllegalOrderThread = new CreateIllegalOrderThread();
+ createIllegalOrderThread.start();
+
+ //Start list order thread
+ ListOrderThread listOrderThread = new ListOrderThread();
+
+ DateFormat currentDateFormat = new SimpleDateFormat("dd MMM yyyy");
+ //remove the necessary line again to see if CG triggers again
+ //currentDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ listOrderThread.setDate(currentDateFormat.format(new Date()));
+
+ listOrderThread.start();
+ }
+}
+
diff --git a/src/main/java/com/company/sample/application/Util.java b/src/main/java/com/company/sample/application/Util.java
new file mode 100644
index 0000000..c513a33
--- /dev/null
+++ b/src/main/java/com/company/sample/application/Util.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: MIT-0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.company.sample.application;
+
+import java.util.*;
+
+public class Util {
+ /**
+ * generate a random date in this year
+ * @return
+ */
+ public static Date getRandomDate(){
+
+ GregorianCalendar gc = new GregorianCalendar();
+
+ int dayOfYear = randBetween(1, gc.getActualMaximum(gc.DAY_OF_YEAR));
+
+ gc.set(gc.DAY_OF_YEAR, dayOfYear);
+
+ return gc.getTime();
+ }
+
+ /**
+ * get a random number between start and end
+ * @param start
+ * @param end
+ * @return
+ */
+ public static int randBetween(int start, int end) {
+ return start + (int)Math.round(Math.random() * (end - start));
+ }
+
+ /**
+ * Judge two dates are in the same day
+ * @param date1
+ * @param date2
+ * @return
+ */
+ public static boolean isSameDay(Date date1, Date date2) {
+ if(date1 == null && date2 == null) {
+ throw new IllegalArgumentException("The date must not be null");
+ }
+ //logic to compare the dates and return boolean.
+ Calendar cal1 = Calendar.getInstance();
+ Calendar cal2 = Calendar.getInstance();
+ cal1.setTime(date1);
+ cal2.setTime(date2);
+ return cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR);
+ }
+
+ public static int test(int len) {
+ int test = 0;
+ for(int i=0; i repo = new HashMap();
+ if(repo.containsKey(ip)) {
+ return repo.get(ip);
+ }
+ return "";
+ }
+}
+
diff --git a/target/classes/com/company/sample/application/App.class b/target/classes/com/company/sample/application/App.class
new file mode 100644
index 0000000..1b92693
Binary files /dev/null and b/target/classes/com/company/sample/application/App.class differ
diff --git a/target/classes/com/company/sample/application/CreateIllegalOrderThread.class b/target/classes/com/company/sample/application/CreateIllegalOrderThread.class
new file mode 100644
index 0000000..4b65aa4
Binary files /dev/null and b/target/classes/com/company/sample/application/CreateIllegalOrderThread.class differ
diff --git a/target/classes/com/company/sample/application/CreateOrderThread.class b/target/classes/com/company/sample/application/CreateOrderThread.class
new file mode 100644
index 0000000..400cf94
Binary files /dev/null and b/target/classes/com/company/sample/application/CreateOrderThread.class differ
diff --git a/target/classes/com/company/sample/application/ListOrderThread.class b/target/classes/com/company/sample/application/ListOrderThread.class
new file mode 100644
index 0000000..c0bf5c1
Binary files /dev/null and b/target/classes/com/company/sample/application/ListOrderThread.class differ
diff --git a/target/classes/com/company/sample/application/Order.class b/target/classes/com/company/sample/application/Order.class
new file mode 100644
index 0000000..d4f32ac
Binary files /dev/null and b/target/classes/com/company/sample/application/Order.class differ
diff --git a/target/classes/com/company/sample/application/ProductName.class b/target/classes/com/company/sample/application/ProductName.class
new file mode 100644
index 0000000..7ba51cf
Binary files /dev/null and b/target/classes/com/company/sample/application/ProductName.class differ
diff --git a/target/classes/com/company/sample/application/SalesSystem.class b/target/classes/com/company/sample/application/SalesSystem.class
new file mode 100644
index 0000000..887326a
Binary files /dev/null and b/target/classes/com/company/sample/application/SalesSystem.class differ
diff --git a/target/classes/com/company/sample/application/Util.class b/target/classes/com/company/sample/application/Util.class
new file mode 100644
index 0000000..ed2d460
Binary files /dev/null and b/target/classes/com/company/sample/application/Util.class differ