BAEL-3326, "Optimizing JSON Schema for production use":
Added percentages, fixed formatting.
This commit is contained in:
		
							parent
							
								
									9d326b55bc
								
							
						
					
					
						commit
						2c78247c95
					
				| @ -32,10 +32,14 @@ class JsonOptimizationUnitTest { | |||||||
|     private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###,###"); |     private static DecimalFormat LENGTH_FORMATTER = new DecimalFormat("###,###,###"); | ||||||
|     private static Customer[] customers; |     private static Customer[] customers; | ||||||
|     private ObjectMapper mapper; |     private ObjectMapper mapper; | ||||||
|  |     private static int defaultJsonLength; | ||||||
| 
 | 
 | ||||||
|     @BeforeAll |     @BeforeAll | ||||||
|     static void setUpOnce() throws Exception { |     static void setUpOnce() throws Exception { | ||||||
|         customers = Customer.fromMockFile(); |         customers = Customer.fromMockFile(); | ||||||
|  |         ObjectMapper oneTimeMapper = new ObjectMapper(); | ||||||
|  |         byte[] feedback = oneTimeMapper.writeValueAsBytes(customers); | ||||||
|  |         defaultJsonLength = feedback.length; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @BeforeEach |     @BeforeEach | ||||||
| @ -135,7 +139,8 @@ class JsonOptimizationUnitTest { | |||||||
|         gzipStream.write(plainJson); |         gzipStream.write(plainJson); | ||||||
|         gzipStream.close(); |         gzipStream.close(); | ||||||
|         byte[] gzippedJson = outpuStream.toByteArray(); |         byte[] gzippedJson = outpuStream.toByteArray(); | ||||||
|         System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length)); |         int percent = gzippedJson.length * 100 / defaultJsonLength; | ||||||
|  |         System.out.println(label + " GZIPped length: " + LENGTH_FORMATTER.format(gzippedJson.length / 1024) + "kB (" + percent + "%)"); | ||||||
|         assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); |         assertTrue(plainJson.length > gzippedJson.length, label + " should be longer than GZIPped data"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -145,7 +150,8 @@ class JsonOptimizationUnitTest { | |||||||
|         System.out.println(prettyWritter.writeValueAsString(customers[0])); |         System.out.println(prettyWritter.writeValueAsString(customers[0])); | ||||||
| 
 | 
 | ||||||
|         byte[] feedback = mapper.writeValueAsBytes(customers); |         byte[] feedback = mapper.writeValueAsBytes(customers); | ||||||
|         System.out.println(label + " length:         " + LENGTH_FORMATTER.format(feedback.length)); |         int percent = feedback.length * 100 / defaultJsonLength; | ||||||
|  |         System.out.println(label + " length:         " + LENGTH_FORMATTER.format(feedback.length / 1024) + "kB (" + percent + "%)"); | ||||||
|         assertTrue(feedback.length > 1, label + " should be there"); |         assertTrue(feedback.length > 1, label + " should be there"); | ||||||
| 
 | 
 | ||||||
|         String prefix = label.replaceAll(" ", "-") |         String prefix = label.replaceAll(" ", "-") | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user