.PHONY: setup build test bench clean install

setup:
	pip install -e ".[dev]"

build:
	cmake -B build -DCMAKE_BUILD_TYPE=Release
	cmake --build build -j$$(nproc)

install:
	pip install . --force-reinstall --no-deps

test:
	pip install . --force-reinstall --no-deps -q
	pytest tests/ -v --noconftest -p no:cacheprovider --tb=short

bench:
	pip install . --force-reinstall --no-deps -q
	python3 -c "\
	from _llm_watermark import WatermarkConfigCXX, WatermarkProcessorCXX;\
	import time;\
	cfg = WatermarkConfigCXX(2.0, 0.5, 42);\
	proc = WatermarkProcessorCXX(cfg);\
	N=1000; V=128000;\
	t0=time.perf_counter();\
	[proc.get_green_mask(i, V) for i in range(N)];\
	pt=(time.perf_counter()-t0)/N*1000;\
	print(f'128K vocab: {pt:.3f} ms/token')"

clean:
	rm -rf build *.egg-info src/*.egg-info
