Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java @ 22527:114a6a77b440
Colorifying ByteValueProfile sample code
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 30 Dec 2015 15:33:13 +0100 |
parents | a63bda98cfdb |
children | 4ba1aa33fda4 |
comparison
equal
deleted
inserted
replaced
22526:a5e58793bbca | 22527:114a6a77b440 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.api.profiles; | 23 package com.oracle.truffle.api.profiles; |
24 | 24 |
25 import com.oracle.truffle.api.nodes.Node; | |
25 import static org.hamcrest.CoreMatchers.is; | 26 import static org.hamcrest.CoreMatchers.is; |
26 import static org.junit.Assert.assertEquals; | 27 import static org.junit.Assert.assertEquals; |
27 import static org.junit.Assert.assertThat; | 28 import static org.junit.Assert.assertThat; |
28 | 29 |
29 import org.junit.Before; | 30 import org.junit.Before; |
111 assertThat(p.profile(VALUE2), is(VALUE2)); | 112 assertThat(p.profile(VALUE2), is(VALUE2)); |
112 assertThat(p.profile(VALUE3), is(VALUE3)); | 113 assertThat(p.profile(VALUE3), is(VALUE3)); |
113 p.toString(); // test that it is not crashing | 114 p.toString(); // test that it is not crashing |
114 } | 115 } |
115 | 116 |
117 // BEGIN: ByteValueProfileSample | |
118 class SampleNode extends Node { | |
119 final ByteValueProfile profile = ByteValueProfile.createIdentityProfile(); | |
120 | |
121 byte execute(byte input) { | |
122 byte profiledValue = profile.profile(input); | |
123 // compiler may know now more about profiledValue | |
124 return profiledValue; | |
125 } | |
126 } | |
127 // END: ByteValueProfileSample | |
116 } | 128 } |