|
1 | 1 | package org.openapex.samples.misc.instrument; |
2 | 2 |
|
| 3 | +import lombok.AllArgsConstructor; |
| 4 | +import lombok.Data; |
| 5 | + |
3 | 6 | import java.io.File; |
4 | 7 | import java.lang.instrument.Instrumentation; |
| 8 | +import java.util.HashMap; |
| 9 | +import java.util.Map; |
5 | 10 |
|
6 | 11 | public class ObjectSize { |
7 | 12 | public static void main(String[] args) { |
8 | 13 | File f = new File("data/user.csv"); |
9 | 14 | String hello = "Hello World"; |
10 | 15 | Integer num = Integer.valueOf(100); |
11 | | - System.out.println("Size of file object (bytes): "+MyInstrumentationAgent.getObjectSize(f)); |
12 | | - System.out.println("Size of string (bytes): "+MyInstrumentationAgent.getObjectSize(hello)); |
13 | | - System.out.println("Size of integer (bytes): "+MyInstrumentationAgent.getObjectSize(num)); |
| 16 | + Map<Integer, Employee> employees = new HashMap<>(); |
| 17 | + employees.put(1, new Employee("abc", "address1")); |
| 18 | + employees.put(2, new Employee("def", "address2")); |
| 19 | + employees.put(3, new Employee("ghi", "address3")); |
| 20 | + employees.put(4, new Employee("jkl", "address4")); |
| 21 | + System.out.println("Size of file object (bytes): " + MyInstrumentationAgent.getObjectSize(f)); |
| 22 | + System.out.println("Size of string (bytes): " + MyInstrumentationAgent.getObjectSize(hello)); |
| 23 | + System.out.println("Size of integer (bytes): " + MyInstrumentationAgent.getObjectSize(num)); |
| 24 | + System.out.println("Size of map (bytes): " + MyInstrumentationAgent.getObjectSize(employees)); |
| 25 | + } |
| 26 | + |
| 27 | + @Data |
| 28 | + @AllArgsConstructor |
| 29 | + private static class Employee { |
| 30 | + private String name; |
| 31 | + private String address; |
14 | 32 | } |
15 | 33 | } |
0 commit comments