Toyota Tercel 1991, 170k. Compression 65, 100,
The answer to your question largely depends upon the overall vehicle condition, how fat your wallet is and how much time you want or can spend on this.
Likely, you can search around and find a good similar used vehicle for what a used engine will cost you.
If you like your vehicle and really want to re-power it, you need to be careful what you buy. Years ago, just about anything would fit into anything and if it didn't it was easy to modify it so it would.Government regulations and constant changes to computer systems pretty much prevent that now, leaving you with limited choices, most of which will have similar miles and wear to yours.
Rebuilding an engine is not terribly complicated but you need to pay attention to details. Cylinder walls need to be re-finished, bearing clearances need to be exact and valves, cam(s) and all other items need to be wear free and pretty much perfect. Set-up is precision work and should not be done by anyone who does not have a clear understanding of what each component does, how it interacts with other parts and what it's limitations are. Special tools are needed (torque wrenches, dial indicators, valve and ring compressors etc). That said, a good rebuild that is done carefully will often outlast the original. Drawback is that parts, machine work and extra tools are expensive. A new engine moves around till the block takes a set. A good used block will not do this, therefore any machine work stays put and does not change after start up and use.
Last, before scraping your engine or car, find out if the problem is caused by bad piston rings, valves or head gasket/cyloinder head. If you find you have burned or unseated valves, you may want to just replace the head and gasket, not the entire engine. A good way to determine what is wrong with yours is to do a cylinder leakdown test. During that test, air escaping from the valve cover indicates bad rings. Air from exhaust is from bad exhaust valves, from intake, is due to bad intake valves.
This may help you to decide which way to go.
Bottom line is that the end decision is yours.
good luck