Americans, and friends of the U.S., often reassure themselves about its relative decline in the following way. Even if the roads, airports and schools continue to slide, it will retain its lead in the most sophisticated fields for decades.

They include defense, elite universities, and, in the business world, technology.

The U.S. may have ceded the top spot to China in exports in 2007, and manufacturing in 2011, and be on track to lose its lead in absolute GDP by about 2030. But Silicon Valley, the argument goes, is still where the best ideas, smartest money and hungriest entrepreneurs combine with a bang nowhere else can match. Or is it?

U.S. attitudes toward Chinese tech have passed through several stages of denial in the past 20 years. First it was an irrelevance, then Chinese firms were sometimes seen as copycats or as industrial spies, and more recently China has been viewed as a tech Galapagos, where unique species grow that would never make it beyond its shores. Now a fourth stage has begun, marked by fear that China is reaching parity. The United States' tech's age of "imperial arrogance" is ending, said one Silicon Valley figure.

China's tech leaders love visiting California, and invest there, but are no longer awed by it. By market value China's giants, Alibaba and Tencent, are in the same league as Alphabet and Facebook. New stars may float their shares in 2018-19, including Didi Chuxing (taxi rides), Ant Financial (payments) and Lufax (wealth management). China's e-commerce sales are double that of the U.S. and the Chinese send 11 times more money by mobile phones than Americans, who still scribble checks.

The venture capital industry is booming. U.S. visitors return from Beijing, Hangzhou and Shenzhen blown away by the entrepreneurial work ethic. Last year, the government decreed that China would lead globally in artificial intelligence by 2030. The plan covers a startlingly vast range of activities, including developing smart cities and autonomous cars and setting global tech standards. Like Japanese industry in the 1960s, private Chinese firms take this "administrative guidance" seriously.

Being a global tech hegemon has been lucrative for the United States. Tech firms support 7 million jobs at home that pay twice the average wage. Other industries benefit by using technology more actively and becoming more productive: American nontech firms are 50 percent more "digitized" than European ones, said McKinsey, a consulting firm. The United States sets many standards, for example on the design of USB ports, or rules for content online, that the world follows. And the $180 billion of foreign profits that U.S. tech firms mint annually is a boon several times greater than the benefit of having the world's reserve currency.

A loss of these spoils would be costly and demoralizing. Is it likely? The Economist has compiled 10 measures of tech supremacy. The approach owes much to Kai-Fu Lee of Sinovation Ventures, a Chinese VC firm. It uses figures from AllianceBernstein, Bloomberg, CB Insights, Goldman Sachs and McKinsey and includes 3,000 listed, global tech firms, 226 "unicorns," or unlisted firms worth over $1 billion, plus Huawei, a Chinese hardware giant.

The overall conclusion is that China is still behind. Using the median of the yardsticks, its tech industry is 42 percent as powerful as America's. But it is catching up fast. In 2012, the figure was just 15 percent.

Start with Chinese tech's weak spots. Its total market value is only 32 percent of the figure for America's industry. While there are two huge companies and lots of small ones, there are relatively few firms worth between $50 billion and $200 billion. China is puny in semiconductors and business-facing software. Tech products do not yet permeate the industrial economy: Chinese nontech firms are relatively primitive and only 26 percent as digitized as American ones.

As for investment, Chinese tech's absolute budget is only 30 percent as big as that of American tech. And it is still small abroad, with foreign sales of 18 percent of the total that American firms make. Apple rakes in more abroad in three days than Tencent does in a year.

The gap gets much smaller, however, when you look at the most dynamic parts of the tech industry. In the area of e-commerce and the internet, Chinese firms are collectively 53 percent as big as America's, measured by market value. China's unicorns, a proxy for the next generation of giants, are in total worth 69 percent of America's, and its level of VC activity is 85 percent as big as America's based on money spent since 2016. There is now a rich ecosystem of VC firms buttressed by Alibaba and Tencent, who seed roughly a quarter of VC deals, and by government-backed funds-of-funds.

China is improving at "breakthrough" innovations. Take AI. China's population of AI experts is only 6 percent of the size of America's (if you include anyone of Chinese ethnicity this rises to 16 percent) and the best minds still work in the United States, for example at Alphabet.

But now the number of cited AI papers by Chinese scientists is already at 89 percent of the American level. China has piles of data and notable companies in AI, for example Face++ in facial recognition and iFlytek in speech.

At the present pace, China's tech industry will be at parity with America's in 10 to 15 years. This will boost the country's productivity and create tech jobs. But the real prize is making far more profits overseas and setting global standards. Here the state's active role may make some countries nervous about relying on Chinese tech firms.

One scenario is that national-security worries mean China's and America's tech markets end up being largely closed to each other, leaving everywhere else as a fiercely contested space. This is how the telecoms-equipment industry works, with Huawei imperious around the world but stymied in America.

For Silicon Valley, it is time to get paranoid. Viewed from China, many of its big firms have become comfy monopolists. In the old days, all American tech executives had to do to see the world's cutting edge was to walk out the door. Now they must fly to China, too. Let's hope the airports still work.