added a small test case for gc
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		| @ -13,7 +13,7 @@ LDFLAGS_COMMON=-L$(abs_builddir)/../lib  -L$(libdir) | |||||||
| ## for more information. | ## for more information. | ||||||
| LIBADD_COMMON = ../lib/libhawk.la $(LIBM) | LIBADD_COMMON = ../lib/libhawk.la $(LIBM) | ||||||
|  |  | ||||||
| check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-009.hawk | check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk | ||||||
| ##noinst_SCRIPTS = $(check_SCRIPTS) | ##noinst_SCRIPTS = $(check_SCRIPTS) | ||||||
| EXTRA_DIST = $(check_SCRIPTS) tap.inc \ | EXTRA_DIST = $(check_SCRIPTS) tap.inc \ | ||||||
| 	journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \ | 	journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \ | ||||||
|  | |||||||
| @ -578,7 +578,7 @@ CPPFLAGS_COMMON = \ | |||||||
| CFLAGS_COMMON =  | CFLAGS_COMMON =  | ||||||
| LDFLAGS_COMMON = -L$(abs_builddir)/../lib  -L$(libdir) | LDFLAGS_COMMON = -L$(abs_builddir)/../lib  -L$(libdir) | ||||||
| LIBADD_COMMON = ../lib/libhawk.la $(LIBM) | LIBADD_COMMON = ../lib/libhawk.la $(LIBM) | ||||||
| check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-009.hawk | check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk | ||||||
| EXTRA_DIST = $(check_SCRIPTS) tap.inc \ | EXTRA_DIST = $(check_SCRIPTS) tap.inc \ | ||||||
| 	journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \ | 	journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \ | ||||||
| 	bibtex-to-html.hawk bibtex-to-html.out | 	bibtex-to-html.hawk bibtex-to-html.out | ||||||
|  | |||||||
							
								
								
									
										37
									
								
								t/h-004.hawk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								t/h-004.hawk
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | |||||||
|  | @pragma entry main | ||||||
|  | @pragma implicit off | ||||||
|  |  | ||||||
|  | @include "tap.inc"; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | function run_gc_test () | ||||||
|  | { | ||||||
|  | 	@local i, a, b, ts, pr, cpr; | ||||||
|  |  | ||||||
|  | 	tap_ensure (hawk::GC_NUM_GENS, 3, @SCRIPTNAME, @SCRIPTLINE); | ||||||
|  | 	hawk::gc_set_threshold(0, 30); | ||||||
|  | 	ts = hawk::gc_get_threshold(0); | ||||||
|  | 	tap_ensure (ts, 30, @SCRIPTNAME, @SCRIPTLINE); | ||||||
|  |  | ||||||
|  | 	pr = hawk::gc_get_pressure(0); | ||||||
|  | 	for (i = 0; i < 50; i++) | ||||||
|  | 	{ | ||||||
|  | 		a[1] = 999; ## there is only 1 allocation that's concerting GC in the current implementation | ||||||
|  | 		b = a; | ||||||
|  | 		b = @nil; | ||||||
|  | 		a = @nil; | ||||||
|  |  | ||||||
|  | 		cpr =  hawk::gc_get_pressure(0); | ||||||
|  | 		if (pr + i + 1 <= ts) | ||||||
|  | 			tap_ensure (cpr, pr + i + 1, @SCRIPTNAME, @SCRIPTLINE); | ||||||
|  | 		else ## gc kicks in when the pressure reaches the threshold, the pressure drops... | ||||||
|  | 			tap_ensure (cpr, (pr + i + 1) - ts, @SCRIPTNAME, @SCRIPTLINE); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function main() | ||||||
|  | { | ||||||
|  | 	run_gc_test(); | ||||||
|  | 	tap_end (); | ||||||
|  | } | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user